comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: how many array elements with a certain value in a row
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: how many array elements with a certain value in a row [message #70269 is a reply to message #70268] Thu, 01 April 2010 08:11 Go to previous messageGo to previous message
Jeremy Bailin is currently offline  Jeremy Bailin
Messages: 618
Registered: April 2008
Senior Member
On Apr 1, 10:14 am, Chris W <cwood1...@gmail.com> wrote:
> On Apr 1, 8:56 am, Jeremy Bailin <astroco...@gmail.com> wrote:
>
>
>
>
>
>> On Apr 1, 9:48 am, Chris W <cwood1...@gmail.com> wrote:
>
>>> On Apr 1, 7:49 am, Jeremy Bailin <astroco...@gmail.com> wrote:
>
>>>> Does anyone have a nice simple efficient solution to this problem (I
>>>> have a simple inefficient solution and a vague sketch in my mind of a
>>>> convoluted but probably efficient solution):
>
>>>> I have an image in which many pixels are saturated (=65535, they're
>>>> short unsigned). I want to treat each set of consecutive saturated
>>>> pixels in a row as a single unit and know how many saturated pixels in
>>>> a row there are. So I would like to have a list that contains (a) the
>>>> rightmost pixel of each set of consecutive saturated pixels, and (b)
>>>> how many saturated pixels there were in the set.
>
>>>> Any suggestions?
>
>>>> -Jeremy.
>
>>> create an array the same size as the image, with values equal to the x
>>> index ([0,1,2,3,4,5,.....]:
>
>>> x = indgen(512)
>>> rx = rebin(x,512,512)
>
>>> ;;create a mask
>>> mask = image eq 65535
>
>>> ;; index values of the mask
>>> rxmask = rx*mask
>
>>> rightvalues = max(rxmask, dimension=1)
>
>>> number_in_rows = total(mask, 1)
>
>> No, that won't work - it will only pick up one set per row. There
>> could be none or many sets in a ny given row.
>
>> -Jeremy.
>
> How about using reform to convert the 2d image into a vector, use
> label region to number each set, then histogram with reverse_indices
> to find the coordinates of each set (the number in each set will be
> the histogram values).
>
> Chris

Yeah, that's good - it's basically what Ben was suggesting, but doing
that reform at the beginning takes away a lot of the extra bookkeeping
that was making me avoid it. Just need to throw an extra column of 0s
at the edge of the image before the reform to make sure that a run at
the end of one row doesn't get attached to any at the beginning of the
next row.

Thanks!

-Jeremy.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: IDL: problem on reading ncdf file with short type data
Next Topic: Re: Image error calculation

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 20:14:10 PDT 2025

Total time taken to generate the page: 0.00479 seconds