Remove background portion

3 次查看(过去 30 天)
ws
ws 2011-10-7
移动DGM 2023-2-14
Hi
May I know how to remove background by using original image's binary image? I found that I can use element wise multiplication with original mammogram to obtain the image I want, but how?
Thank you.
  1 个评论
Walter Roberson
Walter Roberson 2011-10-7
My browser can't bring up that file... some problem with redirection for the site logo.

请先登录,再进行评论。

回答(3 个)

Walter Roberson
Walter Roberson 2011-10-7
MaskedImage = MammogramImage .* repmat(BinaryImage,1,1,size(MammogramImage,3));
Anything set (1) in the binary image would have its corresponding position preserved, and anything clear (0) in the binary image would result in the correspond image location being zero'd (black).
Note: this won't work very well if the original image is a pseudocolor image ;-)

Image Analyst
Image Analyst 2011-10-7
I can't bring up the image either. I usually "dot multiply" like Walter did, but here's another method for masking that Sean uses:
% Mask the image.
maskedRgbImage = bsxfun(@times, rgbImage, cast(mask,class(rgbImage)));
It's a little more obtuse and cryptic than dot-multiplication but it gets the job done.

ws
ws 2011-10-8
Thanks for the reply. Here is another link: http://imageshack.us/photo/my-images/502/unled1lq.png/
my variables: # original image(unit8): I # binary image(unit8): I2 (only have 0 & 255)
LM = I .* repmat(I2,1,1,size(I,3)); % I cant get this works
LM = bsxfun(@times, I, cast(I, class(I2))); % Cannot get the correct image.
Anything I'm wrong?
  5 个评论
ws
ws 2011-10-8
编辑:Walter Roberson 2017-6-26
The result is the same. Could you guide me through my code? Or any bugs in my code?
% image link: http://peipa.essex.ac.uk/ipa/pix/mias/
clear;
I = imread('mdb041.pgm');
imshow(I);
I = medfilt2(I, [1 5]);
% figure, imshow(I), title('Medfilt');
% Median filtering is a nonlinear operation often used in image processing to reduce "salt and pepper" noise. A median filter is more effective than convolution when the goal is to simultaneously reduce noise and preserve edges.
% Since all the mammograms are in high quality images, there is no need to
% perform median filtering
[x y] = size(I);
% find outer bw image
outer = I;
thres=3;
for i=1:x
for j=1:y
if (outer(i,j)<thres)
outer(i,j)=0; %black
else
outer(i,j)=255; %white
end
end
end
%figure, imshow(outer), title('outer');
% find inner bw image
inner = I;
thres=12;
for i=1:x
for j=1:y
if (inner(i,j)<thres)
inner(i,j)=0;
else
inner(i,j)=255;
end
end
end
%figure, imshow(outer), title('inner');
result = outer - inner;
figure, imshow(result), title('outer - inner');
% RMLO process----------------------------------------
RMLO_result = result;
for i=1:x
for j=1:y
if (RMLO_result(i,j)==255)
RMLO_result(i,j:y)=255;
end
j=1024;
end
end
figure, imshow(RMLO_result), title('pre-RMLO');
RM = I - RMLO_result;
figure, imshow(RM), title('Done RMLO image');
% LMLO process-----------------------------------------
LMLO_result = result;
for i=1:x
for j=y:-1:1
if (LMLO_result(i,j)==255)
LMLO_result(i,j:1024)=255;
LMLO_result(i,1:j)=0;
end
end
end
figure, imshow(LMLO_result), title('pre-LMLO');
%MaskedImage = MammogramImage .* repmat(BinaryImage,1,1,size(MammogramImage,3));
%LM = I .* repmat(LMLO_result,1,1,size(I,3));
%maskedRgbImage = bsxfun(@times, rgbImage, cast(mask,class(rgbImage)));
LM = bsxfun(@times, I, cast(LMLO_result, class(I)));
%%%%%LM = I - LMLO_result;
figure, imshow(LM), title('Done LMLO image');
%Identified LM or RM
mean_LM = mean(LM);
mean_RM = mean(RM);
if mean_LM > mean_RM
view = LM;
disp('Left')
else
view = RM;
disp('Right')
end
%Remove pectoral muscle
% pect = view;
% thres=173;
%
% for i=1:x
% for j=1:y
% if (pect(i,j)<thres)
% pect(i,j)=0; %black
% end
% end
% end
%
% figure,imshow(I3),title('pre-pect');
% a) For every POLE ,it should not exceed no. of pixel travelled by previous
% row
% b) Now if at all Rule a is violating for consecutive 5 times then by keeping
% 45o in mind decrease pole position for next row by 1 and replace all
% pixels with zero up to calculated POLE
ws
ws 2011-10-8
移动:DGM 2023-2-14
Hi,
I'm not sure my method is correct or not, although it's simple, but it works for me.
LM = abs(I - I2)
Thanks for those who try to help me :)

请先登录,再进行评论。

标签

Community Treasure Hunt

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

Start Hunting!

Translated by