MATLAB Answers

process an image using a mask

2 views (last 30 days)
Shimaa Salam
Shimaa Salam on 10 Apr 2019
Commented: Shimaa Salam on 16 Apr 2019
i have an image that i segmented using the image segmenter app in matlab . i need to perform mathmatical operations on the segmented part only (which is all the values greater than zero) while maintaing the same image size .
the segment image function is giving me a mask and a segmented image how do i use this mask to process the pixels where the mask equals (1) and ignore the pixels where the mask equals(0) while maintaining the same image size . i tried the (M=feval (A(this is a function handle),O)) function followed by (M=M(BW)) but it seems to change the image size
clear
close all
clc
N = 256 ;
I = Phantom3D('modified shepp-logan',N) ;
I = squeeze(I(:,128,:)) ;
[BW,O] = segmentImage(I) ;

  2 Comments

Guillaume
Guillaume on 10 Apr 2019
how do i use this mask to process the pixels where the mask equals
It's all going to depend on the processing function. Normally, the function has to be aware of the mask so you'd pass it as an input. If passing the mask is not an option of the function, then either you're out of luck and have to use another function, or you apply the function to the whole image and mask the result afterward.
Shimaa Salam
Shimaa Salam on 10 Apr 2019
ok that is good to know . my function is is radon and iradon do thoes functions accept the use of a mask??
and if i use the mask to the result is it going to effect the time of the processing or the quality of image??

Sign in to comment.

Answers (1)

Guillaume
Guillaume on 10 Apr 2019
No radon and iradon do not know about masking. You will have to pass the whole image. I'm not very familiar with these functions but my understanding is that this would affect the result. However, I think that if you set the pixels outside the mask to zero, then the result won't be affected so
maskedimage = originalimage .* mask;
radon(maskedimage)

  1 Comment

Shimaa Salam
Shimaa Salam on 16 Apr 2019
thank you . but this solution altered the shape of the image

Sign in to comment.

Sign in to answer this question.

Products


Release

R2018b