You definitely do not need LABEL_REGION as far as I understand your
problem. As far as I get it you want to create a new 2D array whose
each element will identify whether the highest DN value for that
location lies in Red, Green or the Blue channel.
If I am right so far, then you are assigning wrongly in your code. In
your example if, say, the blue DN value of a pixel is greater than the
Red and Green value for that pixel, you are assigning the value of
Blue DN value in the imnew array. However, what you should do is to
just assign the lable signifying 'blue' for that pixel. If I assume 1
for Blue, 2 for Green and 3 for Red, I would write the same code as
if im[i, j, 0] qt im[i, j, 1] and im[i, j, 0] qt im[i, j,
2] then imnew[i, j] = 1
So, in the end your imnew array will contain only values 1,2 or 3
which when displayed as a pseudo color image will give you the desired
output.
If, however, you wish to preserve the gray level along with it being
displayed as RGB, you could consider converting your imnew to be a
Integer type of array and than assign the values of the array as:
if im[i, j, 0] qt im[i, j, 1] and im[i, j, 0] qt im[i, j,
2] then imnew[i, j] = 0 * 255 + im[i, j, 0] ; or similarly 1*255 +
im[i, j, 1] and so on
This way if a pixel is of blue color, its value will lie between 0-255
in the output array, if it is green it will be between 256-511 and so
on. But I am not sure how you will display this as your output image
in RGB.
In any case, LABEL_REGION figures nowhere, so stop looking in the
wrong place.
Cheers,
Gaurav


|