process an image using a mask

조회 수: 17 (최근 30일)
Shimaa Salam
Shimaa Salam 2019년 4월 10일
댓글: Meirbek Mussatayev 2021년 8월 4일
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
Guillaume
Guillaume 2019년 4월 10일
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 2019년 4월 10일
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??

댓글을 달려면 로그인하십시오.

답변 (1개)

Guillaume
Guillaume 2019년 4월 10일
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)
  댓글 수: 2
Shimaa Salam
Shimaa Salam 2019년 4월 16일
thank you . but this solution altered the shape of the image
Meirbek Mussatayev
Meirbek Mussatayev 2021년 8월 4일
Yes I think that you can modify and use the following codes:
n = 200; %size of images
x = linspace(-1,1,n);
y = x;
dx = x(2) - x(1); %step in x - used for getting physical value of radon transform coordinate
[X, Y] = meshgrid(x, y);
R = sqrt(X .^ 2 + Y .^ 2); %matrix of radial distance from centre of grid
circular_mask = R < 1;
masked_image = raw_image .* circular_mask;

댓글을 달려면 로그인하십시오.

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by