Applying a mask to a image
7 次查看(过去 30 天)
显示 更早的评论
Hi,
I have 60 CT slices and by applying certain processing steps, now I created maps (maybe we can call this as a mask also) for each one of the slices. What I want to do now is to put my particular mapping on to the original CT slice and see the matching. But the problem is that: I cannot check it by directly looking at the pixel values. Because my mapping's pixel values are between 0 and 114 whereas original CT image's are uint16. Also, adjusting pixel values by multiplying by a certain number cannot be considered as a solution for my problem.
Is there a way like for example: I colorize my mapping as red and when I put my mapping on the original CT image, then matching pixels will be shown as red. Or do you have any other suggestions?
Regards
4 个评论
采纳的回答
Walter Roberson
2012-12-18
CTRGB = cat(3, YourCTImage, YourCTImage, YourCTImage);
hCT = image(CTRGB);
MaskImage(:,:,3) = zeros(size(YourCTImage)); %also sets G plane to 0
MaskImage(:,:,1) = 1;
maskalpha = double(YourCTMask) ./ 114; %1 for maximum count
hMask = image(MaskImage, 'AlphaData', maskalpha); %not imshow() or imagesc()
6 个评论
Walter Roberson
2012-12-18
The line
CTRGB = nii.img(:,:,[slicenum slicenum slicenum]);
is selecting the current slice from the original image. The image() of it is displaying that slice. The assignment to hCT of the image() is giving you the handle of the image object created. In the code shown, that handle is not used because I used cla() to delete all the current axis contents instead of using delete(hCT) and delete(hMask) to delete the two images selectively.
You might possibly want to increase the pause() to 1 or more; that is how long each slice will be displayed. Since you didn't say what you wanted to do with all the various slices, I just display each of them momentarily and go on to the next.
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!