現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
How to remove the pectoral muscle from the mammogram?
8 ビュー (過去 30 日間)
古いコメントを表示
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/195527/image.png)
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.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/195383/image.png)
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;
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/996210/image.png)
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.
参考
カテゴリ
Help Center および File Exchange で Image Processing Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の 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 (한국어)