Re: How to find the pixel position [message #70632] |
Tue, 27 April 2010 02:58  |
Carsten Lechte
Messages: 124 Registered: August 2006
|
Senior Member |
|
|
sid wrote:
> data, but I need to know at which pixel this 5500 counts occur
> exactly, without displaying the image, because I need to do this for
Use WHERE() to find the 1d index of the pixels. If WHERE() delivers a
count of more than zero indices, use ARRAY_INDICES() to convert these
1d indices to x and y indices for your 2d data array.
chl
|
|
|
Re: How to find the pixel position [message #70636 is a reply to message #70632] |
Mon, 26 April 2010 23:26   |
Craig Markwardt
Messages: 1869 Registered: November 1996
|
Senior Member |
|
|
On Apr 27, 1:16 am, sid <gunvicsi...@gmail.com> wrote:
> Hi,
> My data is in fits format. The is of 1024 * 1024 array. The counts
> vary from 5000 to 6000 and I know that 5500 counts is there in my
> data, but I need to know at which pixel this 5500 counts occur
> exactly, without displaying the image, because I need to do this for
> several files. So each time I can't display and check for the pixel
> position. please helpout in this regard.
> regards
Have you tried WHERE()?
wh = where(IMG EQ 5500)
The pixel position, or position*s* if there more than one, are stored
in the index array WH. This index array addresses the 2-d array as a
1-d array. If you want the X and Y positions separately, then use the
quotient and remainder after dividing by image width...
;; SIZE_X = 1024
ix = wh MOD SIZE_X ;; Remainder
iy = wh / SIZE_X ;; Quotient
Craig
|
|
|
|
Re: How to find the pixel position [message #70678 is a reply to message #70637] |
Thu, 29 April 2010 10:58  |
Chris[6]
Messages: 84 Registered: July 2008
|
Member |
|
|
> Note that the WHERE function returns one-dimensional subscripts. You can
> convert them back to two-dimensional subscripts (if you need to) using
> the ARRAY_INDICES function:
>
> rectIndices = array_indices([1024,1024],findIndices,/dimensions)
Can anyone enlighten me about whether there's any advantage to using
the /dimensons keyword in array_indices? I hear people claim it's to
prevent passing big arrays around, but those big arrays would be
passed by reference, yes? In which case that wouldn't be a problem
chris
|
|
|
Re: How to find the pixel position [message #70697 is a reply to message #70637] |
Wed, 28 April 2010 23:40  |
sid
Messages: 50 Registered: January 1995
|
Member |
|
|
On Apr 27, 11:24 am, Aram Panasenco <panasencoa...@gmail.com> wrote:
> sid wrote:
>> Hi,
>> My data is in fits format. The is of 1024 * 1024 array. The counts
>> vary from 5000 to 6000 and I know that 5500 counts is there in my
>> data, but I need to know at which pixel this 5500 counts occur
>> exactly, without displaying the image, because I need to do this for
>> several files. So each time I can't display and check for the pixel
>> position. please helpout in this regard.
>> regards
>> sid
>
> I think what you are saying (correct me if I am wrong) is that you have
> a 1024x1024 array, and you want to find where the pixel values are equal
> to 5500.
>
> You can use the WHERE function:
>
> fitsData = readfits('filename.fits')
> countValue = 5500
>
> findIndices = where(fitsData eq countValue)
>
> Note that the WHERE function returns one-dimensional subscripts. You can
> convert them back to two-dimensional subscripts (if you need to) using
> the ARRAY_INDICES function:
>
> rectIndices = array_indices([1024,1024],findIndices,/dimensions)
>
> Cheers
> ~Aram Panasenco
Hi,
I did like this
raw=readfits('filename.fits')
b=where(raw eq 2832.90)
I know that it occurs at raw(5,5)
so now if I do
print,b
it should print 5, since where function returns one dimensional
subscripts.(am I right, correct me if it is wrong)
but instead it is printing -1. Please help me out.
regards
sid
|
|
|