How to find the pixel position [message #70640] |
Mon, 26 April 2010 22:16  |
sid
Messages: 50 Registered: January 1995
|
Member |
|
|
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
|
|
|
Re: How to find the pixel position [message #70672 is a reply to message #70640] |
Thu, 29 April 2010 12:46   |
Aram Panasenco
Messages: 41 Registered: April 2010
|
Member |
|
|
sid wrote:
> 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
Hey sid, other people have explained what your problem is already (can't
compare float-point values in IDL). If you want to read a more detailed
discussion on the subject, check out this article by David Fanning:
http://www.dfanning.com/code_tips/comparearray.html
~Aram Panasenco
|
|
|
Re: How to find the pixel position [message #70677 is a reply to message #70640] |
Thu, 29 April 2010 11:42   |
Aram Panasenco
Messages: 41 Registered: April 2010
|
Member |
|
|
Chris wrote:
>
>> 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
>
In IDL, it is _usually_ a bad idea to pass a variable that you don't
want modified into a routine, because it is so easy for the routine to
change it. Now, array_indices() does not do that for a fact, but for me
personally it's just a matter of consistency.
~Aram Panasenco
|
|
|
|
Re: How to find the pixel position [message #70688 is a reply to message #70640] |
Thu, 29 April 2010 03:22   |
d.poreh
Messages: 406 Registered: October 2007
|
Senior Member |
|
|
On Apr 29, 2:49 am, Timm Weitkamp <weitk...@esrf.fr> wrote:
> On Apr 29, 10:50 am, sid <gunvicsi...@gmail.com> wrote:
>
>
>
>
>
>> On Apr 29, 12:06 pm, Dave Poreh <d.po...@gmail.com> wrote:
>
>>> On Apr 28, 11:40 pm, sid <gunvicsi...@gmail.com> wrote:
>
>>>> 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
>
>>> Look at the data type: float double integer?
>
>> data type is float
>
> Trying to find "equality" between two float expressions is like trying
> to put a pencil upright on its tip and hoping that it will not fall
> over. It will hardly ever work. One solution could be to replace the
> line "b=where(...)" in your code by
>
> myval = 2832.90
> epsilon = .05
> b = where(ABS(raw-myval) LE epsilon)
>
> Timm
Or fix(myval*100) then search for data with where(...)
|
|
|
Re: How to find the pixel position [message #70689 is a reply to message #70640] |
Thu, 29 April 2010 02:49   |
Timm Weitkamp
Messages: 66 Registered: August 2002
|
Member |
|
|
On Apr 29, 10:50 am, sid <gunvicsi...@gmail.com> wrote:
> On Apr 29, 12:06 pm, Dave Poreh <d.po...@gmail.com> wrote:
>
>
>
>> On Apr 28, 11:40 pm, sid <gunvicsi...@gmail.com> wrote:
>
>>> 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
>
>> Look at the data type: float double integer?
>
> data type is float
Trying to find "equality" between two float expressions is like trying
to put a pencil upright on its tip and hoping that it will not fall
over. It will hardly ever work. One solution could be to replace the
line "b=where(...)" in your code by
myval = 2832.90
epsilon = .05
b = where(ABS(raw-myval) LE epsilon)
Timm
|
|
|
Re: How to find the pixel position [message #70692 is a reply to message #70640] |
Thu, 29 April 2010 01:50   |
sid
Messages: 50 Registered: January 1995
|
Member |
|
|
On Apr 29, 12:06 pm, Dave Poreh <d.po...@gmail.com> wrote:
> On Apr 28, 11:40 pm, sid <gunvicsi...@gmail.com> wrote:
>
>
>
>> 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
>
> Look at the data type: float double integer?
data type is float
|
|
|
Re: How to find the pixel position [message #70696 is a reply to message #70640] |
Thu, 29 April 2010 00:06   |
d.poreh
Messages: 406 Registered: October 2007
|
Senior Member |
|
|
On Apr 28, 11:40 pm, sid <gunvicsi...@gmail.com> wrote:
> 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
Look at the data type: float double integer?
|
|
|
Re: How to find the pixel position [message #70755 is a reply to message #70672] |
Thu, 29 April 2010 23:30  |
sid
Messages: 50 Registered: January 1995
|
Member |
|
|
On Apr 30, 12:46 am, Aram Panasenco <panasencoa...@gmail.com> wrote:
> sid wrote:
>> 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
>
> Hey sid, other people have explained what your problem is already (can't
> compare float-point values in IDL). If you want to read a more detailed
> discussion on the subject, check out this article by David Fanning:
>
> http://www.dfanning.com/code_tips/comparearray.html
>
> ~Aram Panasenco
Thanks a lot for everybody's help and suggestions.
regards
sid
|
|
|