From: Wendy on
Hi all,

I read in a matrix from xls file. The matrix is as follows

pvalue = [ NaN NaN NaN NaN;
NaN NaN 1.00000000000000e-05 NaN;
NaN 4.00000000000000e-05 0 NaN;
NaN 0 0 NaN;
NaN NaN NaN NaN];

All the NaN are empty elements in the excel file. I want to plot the pvalue using imagesc and indicate the empty elements as the background colour. However, Matlab treats the NaN as the minimum value (0) and indicates those 'NaN' positions blue on the plot. Is there a way that I can plot the 'NaN' elements as the background colour and only plot those elements that I have value with?

Hope I made the question clear. Thank you very much,
Wendy
From: ImageAnalyst on
Wendy:
In order to assign it a color, it has to have a value. You can assign
the nan's a value like this:
pvalue(isnan(pvalue)) = desiredValue;
If desiredValue already exists in your pvalue array, then you those
will be indistinguishable from the nans that were newly set to the
same values. You can maybe set it up to use some unused value - take
the histogram and check for gaps. If, say, you're using uint8 values
and every value from 0 to 255 is being used by some pixel, then I
think you'd need to reuse a value.

Anyway, once you've set the nan's to the new value, then you need to
set up a colormap where the color at the index of the new value is the
color that you desire the nan pixels to have.
From: Wendy on
Thank you very much, ImageAnalyst. As all my pvalues are >=0, I assigned a negative value to NaN elements (-2), and I set caxis to [0 max(max(pvalues))]. The -2 elements are still treated as minimum number. Do you mind to give some hint on how to set a value to the desiredValue, for example, set -2 elements to grey. What functions shall I look at in matlab?

Thank you,
Wendy


ImageAnalyst <imageanalyst(a)mailinator.com> wrote in message <9d837299-3209-4da3-84ef-117ccf1919d4(a)y17g2000yqd.googlegroups.com>...
> Wendy:
> In order to assign it a color, it has to have a value. You can assign
> the nan's a value like this:
> pvalue(isnan(pvalue)) = desiredValue;
> If desiredValue already exists in your pvalue array, then you those
> will be indistinguishable from the nans that were newly set to the
> same values. You can maybe set it up to use some unused value - take
> the histogram and check for gaps. If, say, you're using uint8 values
> and every value from 0 to 255 is being used by some pixel, then I
> think you'd need to reuse a value.
>
> Anyway, once you've set the nan's to the new value, then you need to
> set up a colormap where the color at the index of the new value is the
> color that you desire the nan pixels to have.
From: Wendy on
Thank you very much. As all my pvalues are >=0, I assigned -2 to NaN elements, then I set caxis([0 max(max(pvalue))]. However, -2 elements are still treated as minimum values as they outside the caxis. Do you mind to give me some hint on how to set -2 elements to grey color? What functions shall I look at in matlab?

Thank you very much.
Wendy

ImageAnalyst <imageanalyst(a)mailinator.com> wrote in message <9d837299-3209-4da3-84ef-117ccf1919d4(a)y17g2000yqd.googlegroups.com>...
> Wendy:
> In order to assign it a color, it has to have a value. You can assign
> the nan's a value like this:
> pvalue(isnan(pvalue)) = desiredValue;
> If desiredValue already exists in your pvalue array, then you those
> will be indistinguishable from the nans that were newly set to the
> same values. You can maybe set it up to use some unused value - take
> the histogram and check for gaps. If, say, you're using uint8 values
> and every value from 0 to 255 is being used by some pixel, then I
> think you'd need to reuse a value.
>
> Anyway, once you've set the nan's to the new value, then you need to
> set up a colormap where the color at the index of the new value is the
> color that you desire the nan pixels to have.
From: ImageAnalyst on
I don't know - you'd have to experiment. I rarely use imagesc,
favoring imshow instead. And when I apply a pseudocolor lookup table
(colormap) I'm always dealing with non-negative pixel values.
 | 
Pages: 1
Prev: MATLAB on the iPad
Next: Making a Memo box Dialog