이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
How to remove the pectoral muscle from the mammogram?
조회 수: 2 (최근 30일)
이전 댓글 표시
I used imclearborder() but it doesn’t work. Can anyone give me advice?! i want to remove the left part behind the red line
댓글 수: 13
Image Analyst
2018년 9월 10일
Why is there an intensity discontinuity in the top band of the image? Will all your images have that? Will all images have the pectoral muscle separated from the breast by a dark region, or will the breast be just as bright, and connected to, the pectoral region in some images?
Can you attach the original image, without the red annotation line?
Image Analyst
2018년 9월 10일
And can you attach your code that you have so far? I doubt whatever I think of off the top of my head will be as robust as those methods that people have worked on for months and perfected.
Afaf Saad
2018년 9월 10일
편집: Afaf Saad
2018년 9월 10일
yes, pectoral muscle removal is the second step i want to do because i want to train Convolution neural network with those images after getting ROI. i extracted the whole breast but i want to remove this part to improve the segmented images. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%555 clc;
close all
clear;
%load image from my directory
folder='C:\Users\afaf\Documents\MATLAB\all-mias\NormaL';
newfolder='C:\Users\afaf\Documents\MATLAB\all-mias\NormalRotated';
filepattern=fullfile(folder,'*.pgm');
myfiles=dir(filepattern);
se = strel('disk',15);
% read images and resize
for k=1:length(myfiles)
images{k}=imread(myfiles(k).name);
images{k} = imresize(images{k},[224 224]);
%to extract the whole breast
BW1 = imbinarize(images{k});
nhood = true(9);
closeBW1 = imclose(BW1,nhood);
roughMask = imfill(closeBW1,'holes');
BW2 = bwareafilt(roughMask,1);
I2=images{k};
I2(~BW2)=0;
images{k}=I2;
temp=images{k};
%normalize the image
images{k}=temp-min(temp(:))/max(temp(:))-min(temp(:));
images{k}=adapthisteq(images{k});
baseFileName = sprintf('Image #%d.png', k);
fullFileName = fullfile(newfolder, baseFileName);
imwrite(images{k}, fullFileName);
%%%%%
end
Image Analyst
2018년 9월 10일
Image Analyst
2018년 9월 10일
That algorithm looks really, really bad and amateurish. Which paper published that one? I find it hard to believe that would work.
Afaf Saad
2018년 9월 10일
this is not the whole system, i didn't finish yet. i followed the attached paper, i did the pre-processing that he mentioned. have a look if there is any comments. and tell me.
Afaf Saad
2018년 9월 10일
it already works, just extracting the whole breast and getting rid of the tags. he didn't mention extra process to do.
답변 (1개)
Image Analyst
2018년 9월 10일
See attached demo.
댓글 수: 11
Image Analyst
2018년 9월 10일
Yes, but I have other stuff to do. This image has different brightness, so why don't you scan the outer edge of the image to find out what a good threshold would be?
Image Analyst
2018년 9월 11일
You can extract the top 3 rows like this
topRows = grayImage(1:3, :);
leftColumns = grayImage(:, 1:3);
rightColumns = grayImage(:, end-2:end);
By looking at those, and assuming that the gray levels will either represent pectoral muscle, or black background, you will be able to determine a good guess for the threshold.
AHT.fatima
2022년 5월 12일
편집: AHT.fatima
2022년 5월 12일
hello to all thank you for your efforts but it only works with this image but not the others. there is a part of the region of interest which is removed when applying the code with another image...please my friends or i add exactly the three lines in this code to remove the pectoral muscle and not a part of ROI and have the best results please...
Image Analyst
2022년 5월 12일
편집: Image Analyst
2022년 5월 12일
@AHT.fatima you forgot to attach the "other image" that it doesn't work for. How can I fix it otherwise? Do we know for a fact that the pectoral muscle will always in in one of the corners?
You say "please my friends or i add exactly the three lines in this code to remove the pectoral muscle" so if I don't write any more code for you, then what are those three lines of code you'll add that will do it?
AHT.fatima
2022년 5월 12일
Thank you for your answer, I am working with this code you shared.. I try it with several photos but it does not give the required results because I want to remove the pectoral muscle to finally only get our ROI without any loss or deletion at its level.
Image Analyst
2022년 5월 12일
@AHT.fatima I don't think that is robust. See my new code below, which is more robust. It deletes any bright blob in the upper right or upper left corner.
The problem is you're dealing with a screenshot rather than the original image. I've made a few changes to just crop the image to what you'd have if you had the original image.
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clearvars; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 20;
folder = pwd;
baseFileName = 'mammo B5.png';
% Get the full filename, with path prepended.
fullFileName = fullfile(folder, baseFileName);
% Check if file exists.
if ~exist(fullFileName, 'file')
% The file doesn't exist -- didn't find it there in that folder.
% Check the entire search path (other folders) for the file by stripping off the folder.
fullFileNameOnSearchPath = baseFileName; % No path this time.
if ~exist(fullFileNameOnSearchPath, 'file')
% Still didn't find it. Alert user.
errorMessage = sprintf('Error: %s does not exist in the search path folders.', fullFileName);
uiwait(warndlg(errorMessage));
return;
end
end
rgbImage = imread(fullFileName);
% Display the image.
subplot(2, 3, 1);
imshow(rgbImage, []);
title('Original RGB Screenshot Image', 'FontSize', fontSize, 'Interpreter', 'None');
hp = impixelinfo;
axis('on', 'image'); % Make sure image is not artificially stretched because of screen's aspect ratio.
% Get the dimensions of the image.
% numberOfColorChannels should be = 1 for a gray scale image, and 3 for an RGB color image.
grayImage = rgbImage; % Initialize.
[rows, columns, numberOfColorChannels] = size(grayImage);
if numberOfColorChannels > 1
% It's not really gray scale like we expected - it's color.
% Use weighted sum of ALL channels to create a gray scale image.
% grayImage = rgb2gray(grayImage);
% ALTERNATE METHOD: Convert it to gray scale by taking only the green channel,
% which in a typical snapshot will be the least noisy channel.
grayImage = grayImage(:, :, 1); % Take red channel.
end
% The image is not the original image - it's a screenshot that has a white frame around it.
% Get rid of white frame and crop image.
grayImage = grayImage(55:1078, 183:951);
% Update image size.
[rows, columns, numberOfColorChannels] = size(grayImage);
% Display the image.
subplot(2, 3, 2);
imshow(grayImage, []);
hp = impixelinfo;
title('Cropped Gray Scale Image', 'FontSize', fontSize, 'Interpreter', 'None');
axis('on', 'image'); % Make sure image is not artificially stretched because of screen's aspect ratio.
%------------------------------------------------------------------------------
% Set up figure properties:
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0, 0.04, 1, 0.96]);
drawnow;
% Display the histogram.
subplot(2, 3, 3);
imhist(grayImage);
grid on;
title('Histogram of Gray Scale Image', 'FontSize', fontSize, 'Interpreter', 'None');
% Turn into a binary image to get the pectoral muscle.
lowThreshold = 130;
highThreshold = 255;
% https://www.mathworks.com/matlabcentral/fileexchange/29372-thresholding-an-image?s_tid=srchtitle
% [lowThreshold, highThreshold] = threshold(lowThreshold, highThreshold, grayImage)
binaryImage = grayImage > lowThreshold & grayImage <= highThreshold;
% Display the binary image.
subplot(2, 3, 4);
imshow(binaryImage, []);
caption = sprintf('Bright Regions Mask Image');
title(caption, 'FontSize', fontSize, 'Interpreter', 'None');
hp = impixelinfo;
axis('on', 'image'); % Make sure image is not artificially stretched because of screen's aspect ratio.
drawnow;
% Extract only blob in the upper left or upper right corners.
pectMask = bwselect(binaryImage, 1, 1) | bwselect(binaryImage, columns, 1);
% Fill holes
binaryImage = imfill(pectMask, 'holes');
% Display the binary image.
subplot(2, 3, 5);
imshow(pectMask, []);
caption = sprintf('Pectoral Mask Image');
title(caption, 'FontSize', fontSize, 'Interpreter', 'None');
hp = impixelinfo;
axis('on', 'image'); % Make sure image is not artificially stretched because of screen's aspect ratio.
drawnow;
% Erase the gray scale image there.
grayImage(pectMask) = 0;
% Display the masked image.
subplot(2, 3, 6);
imshow(grayImage);
axis('on', 'image'); % Make sure image is not artificially stretched because of screen's aspect ratio.
caption = sprintf('Image with Pectoral Muscle Masked out.');
title(caption, 'FontSize', fontSize);
drawnow;
AHT.fatima
2022년 5월 15일
hello everyone, can someone explain this code to me please .... it gives me good results but I did not understand its principle (by the way it is a code for the removal of the pectoral muscle after binarization)...
Image Analyst
2022년 5월 15일
편집: Image Analyst
2022년 5월 15일
I did explain my code, in the comments. Nearly every small snippet of code is explained. Which comment don't you understand? I don't know who wrote that code that you attached. You'd have to ask them if you'd rather use their code than mine. I really don't have time to re-write their code correctly, like by adding in the code missing from the beginning to read in the images and assign variables, put in the missing comments, etc.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
아시아 태평양
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)