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