Filter löschen
Filter löschen

process an image using a mask

17 Ansichten (letzte 30 Tage)
Shimaa Salam
Shimaa Salam am 10 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 Kommentare
Guillaume
Guillaume am 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 am 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??

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Guillaume
Guillaume am 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)
  2 Kommentare
Shimaa Salam
Shimaa Salam am 16 Apr. 2019
thank you . but this solution altered the shape of the image
Meirbek Mussatayev
Meirbek Mussatayev am 4 Aug. 2021
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;

Melden Sie sich an, um zu kommentieren.

Produkte


Version

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by