Re: label_region/histogram help [message #68547] |
Tue, 03 November 2009 14:54  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Dave wrote:
> I need some help on an image I'm working on.
>
> I've got many regions that I've distinguished via LABEL_REGION and
> looked at the population of the regions using HISTOGRAM. Most of
> these regions have a population of less than 5 or so. For these
> regions I have made the population zero by:
>
> im_pop = where(areas lt 5, numbers)
> if numbers lt 5 then area[im_pop]=0
>
> After I've got the populations of my regions where I want, for the
> most part, I need to get all the regions, including the 0 population
> regions, back into pixel space for display. I cannot for the life of
> me figure this out.
Presumably you have your original image, let's call it image.
I assume it is Long Integers.
You have your Label_Region result, call it labelRegion.
So,to restore the regions from your orginal images, you would
do something like this:
s = Size(image, /Dimensions)
displayImage = LonArr(s[0]. s[1])
FOR j=1,Max(labelRegion)-1 DO BEGIN
thisRegion = Where(labelRegion EQ j, count)
IF count EQ 0 THEN Continue
displayImage[thisRegion] = image[thisRegion]
ENDFOR
TVImage, BytScl(displayImage)
This could be faster using the reverse indices to the Histogram
command, but *much* harder to explain. :-)
Cheers,
David
|
|
|
Re: label_region/histogram help [message #68660 is a reply to message #68547] |
Fri, 06 November 2009 09:03  |
david.b.valdez
Messages: 3 Registered: December 2008
|
Junior Member |
|
|
On Nov 3, 3:54 pm, David Fanning <da...@dfanning.com> wrote:
> Dave wrote:
>> I need some help on an image I'm working on.
>
>> I've got many regions that I've distinguished via LABEL_REGION and
>> looked at the population of the regions using HISTOGRAM. Most of
>> these regions have a population of less than 5 or so. For these
>> regions I have made the population zero by:
>
>> im_pop = where(areas lt 5, numbers)
>> if numbers lt 5 then area[im_pop]=0
>
>> After I've got the populations of my regions where I want, for the
>> most part, I need to get all the regions, including the 0 population
>> regions, back into pixel space for display. I cannot for the life of
>> me figure this out.
>
> Presumably you have your original image, let's call it image.
> I assume it is Long Integers.
>
> You have your Label_Region result, call it labelRegion.
>
> So,to restore the regions from your orginal images, you would
> do something like this:
>
> s = Size(image, /Dimensions)
> displayImage = LonArr(s[0]. s[1])
> FOR j=1,Max(labelRegion)-1 DO BEGIN
> thisRegion = Where(labelRegion EQ j, count)
> IF count EQ 0 THEN Continue
> displayImage[thisRegion] = image[thisRegion]
> ENDFOR
> TVImage, BytScl(displayImage)
>
> This could be faster using the reverse indices to the Histogram
> command, but *much* harder to explain. :-)
>
> Cheers,
>
> David
Thanks so much, that's exactly what i was looking for.
Dave
|
|
|