Reputation: 307
I have a matrix representing an image of brain with each (i,j) position having a value between 0 and 1. I am applying a color map, so that those pixels with value 1 are red and 0 are yellow, those in between get intermediary values. Now, what i want is that those pixels having values above 0.8 get color according to colormap and rest become trasparent(that is they dont get any color), so that i can overlay this image with the another image of brain and identify high activity region. How do i do this ?
I want only the bright yellow part, so that i can overlay it with other image and get something like this.
(source: psychcentral.com)
Edit:
I followed the method suggested by Jigg, but recently observed that the final image was rotated and inverted , any idea why ?
Upvotes: 1
Views: 143
Reputation: 3574
Here is another option, create a 3-layers array replicating your grayscale brain image (imagesc
will scale each layer similarly resulting in equal r, g, and b values -> levels of gray).
GrayBckgnd = repmat(brain, [1, 1, 3]);
data = …
Then overlay it with the activity data:
imagesc(GrayBcknd);
hold on;
DataImg = imagesc(data);
set(DataImg, 'AlphaData', im2double(data>0.8));
colormap jet; % or any other colormap.
Upvotes: 3
Reputation: 8677
You can do this by plotting a surf(-ace) and passing in alpha values as follows.
brain = ... % background brain image
data = ... % the data you are trying to overlay
imshow(brain);
hold on;
surf(zeros(size(data)), data, 'AlphaData', data > 0.8);
colormap(...); % whatever colormap you like
Have a look at the surface properties documentation for more options you can pass to surf
.
Upvotes: 2