Applying a mask to a image

12 views (last 30 days)
Amadeus
Amadeus on 18 Dec 2012
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 Comments
Amadeus
Amadeus on 18 Dec 2012
Edited: Amadeus on 18 Dec 2012
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 on 18 Dec 2012
Edited: Amadeus on 18 Dec 2012
@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.

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 18 Dec 2012
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 Comments
Amadeus
Amadeus on 18 Dec 2012
Edited: Amadeus on 18 Dec 2012
./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 on 18 Dec 2012
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.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!