comp.lang.idl-pvwave archive - RDF feed
type: channel
description: Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado
items: Re: shifting a mask over an image

Re: shifting a mask over an image
type: item
description: Den måndagen den 26:e november 2012 kl. 12:13:49 UTC+1 skrev haik...@gmail.com: > Hi, > > I'm trying to move a mask over an image using the shift function. But I'm not sure if I really understood the description in the IDL help. > > Let's say I have a 10x10 mask and a 100x100 image. In this case I have to create an array with the same size as my image. It is filles with 0 and my mask. Then I start moving the mask inside that array (in x direction and y direction). But every time I do it with both direction, there is an error message telling me that I have an incorrect number of arguments. It works fine for one dimension, though. > > Has anyone an idea how I can shift in both directions? > > Btw, my code looks like this: > > for i=0, n-1 do begin > for j=0, n-1 do begin > result=shift(template, shift_x[i], shift_y[j]) > cor=where(max(correlate(result, image)) > endfor > endfor The shift operation should be fine - IF template is a 2D array. If the number of dimensions of template is not 2, you would get the error message you mention. Do a "help template" before you enter the loop. But apart from that, your code looks funny: * The "cor=..." line har three opening parenthesis but only two closing ones so you should get an error from that when you try to run it. * Correlate() returns a scalar so the where(max()) business makes no sense. * And if you are trying to find the location of the pattern in the mask within the image by maximizing the correlation with respect to the shifts, you want to collect the correlation values in an array and then find the location of the maximum after the loop has finished. /Mats
creator: Mats Löfdahl
date: 2012-11-26T12:18:40-00:00

Re: shifting a mask over an image
type: item
description: On Monday, November 26, 2012 12:13:49 PM UTC+1, haik...@gmail.com wrote: > Hi, [...] > Has anyone an idea how I can shift in both directions? The following works for me: template = bytarr(8,8) template[0:2,0:2] = 1 print, template print, shift(template, 1, 2) Does this work for you? If so, your problem lies elsewhere. You have not shown us how 'template' or 'shift_x' and 'shift_y' were generated. --T
creator: tom.grydeland
date: 2012-11-26T12:21:42-00:00

Re: shifting a mask over an image
type: item
description: On Monday, November 26, 2012 12:13:49 PM UTC+1, haik...@gmail.com wrote: > Hi, > > > > I'm trying to move a mask over an image using the shift function. But I'm not sure if I really understood the description in the IDL help. > > > > Let's say I have a 10x10 mask and a 100x100 image. In this case I have to create an array with the same size as my image. It is filles with 0 and my mask. Then I start moving the mask inside that array (in x direction and y direction). But every time I do it with both direction, there is an error message telling me that I have an incorrect number of arguments. It works fine for one dimension, though. > > > > Has anyone an idea how I can shift in both directions? > > > > Btw, my code looks like this: > > > > for i=0, n-1 do begin > > for j=0, n-1 do begin > > result=shift(template, shift_x[i], shift_y[j]) > > cor=where(max(correlate(result, image)) > > endfor > > endfor > > > > > > thanks, > > max Yes, it does work now, thank you very much.
creator: haikoley
date: 2012-11-26T15:41:50-00:00