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 个评论
Amadeus
Amadeus 2012-12-18
编辑:Amadeus 2012-12-18
Walter first of all thank you for your answer. 114 will indicate complete red, if mask value is 0 at a particular pixel, then I want to be able to see the CT image value when I apply the mask. (My mask is supposed to indicate some fibers on the CT data.)
Amadeus
Amadeus 2012-12-18
编辑:Amadeus 2012-12-18
@ImageAnalyst 0-114 (I rechecked now and 180 is wrong) indicates how many fibers go over that voxel. I kept the record of that in order to indicate the voxel with 114 fibers more distinct than a voxel with 8 fibers.
Applying a red color to the mask was just a thought. I tried simply adding my mask to original CT data but output is not very clear. Therefore I am looking for better solutions.

请先登录,再进行评论。

采纳的回答

Walter Roberson
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 个评论
Amadeus
Amadeus 2012-12-18
编辑:Amadeus 2012-12-18
./114 is still there. Here is the whole line:
maskalpha = double(N(:,:,slicenum)) ./ 114; %1 for maximum count
By the way I felt like I am only viewing the slices from the Mask. Exactly which part of the code uses the original CT image slices? hCT seems to be not used.
Walter Roberson
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 个)

类别

Help CenterFile Exchange 中查找有关 Get Started with Image Processing Toolbox 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by