How to remove mammogram tags automatically?

Hi All,
I have mammogram images with label tag (top right corner) on each of every image. How do I remove the tags automatically? Please kindly help and advice. I have uploaded the image below. Thank you very much.

 Accepted Answer

I would use my shrinkWrap function with the 'biggest' option:
% Read and mask image
I = imread('Screenshot 2014-10-29 22.41.29.png');
M = shrinkWrap(I,'biggest');
% Copy and zero out not in the mask
I2 = I;
I2(~M) = 0;
% Show it
imshow(I2)

2 Comments

Dear Sean, your code dont work, could you help please
Try thresholding and using
binaryImage = bwareafilt(binaryImage, 1);
to extract the largest blob (or should I say boob) only.

Sign in to comment.

More Answers (2)

You can use my ExtractNLargestBlobs() function, in my attached ExtractLargestBlob file. Uh, maybe you could rename it ExtractLargestBoob for your case. :-)
Just threshold at some low number and this will take the largest blob (boob) in the image. This will work assuming the breast can be thresholded into one large contiguous region, not several regions, which seems like a good assumption.

8 Comments

Thank you all for the answers that you have provided. I will try both functions and see which suits best for my ExtractLargestBoob :) project.
Epah, your problem below is that you used locally adaptive histogram equalization for some reason. That got rid of the big blob - the main breast - and created lots of smaller blobs. Don't do that (there's absolutely no reason to whatsoever!) and you should be okay.
Hi Image Analyst, I eliminate the locally adaptive histogram equalization and got the results below. I managed to successfully eliminate the tag. My next problem would be how can I revert the binary image back to the breast image? My ideal image would be the one Sean de Wolski had segmented. Thank u.
I manage to revert the image by implementing this code.
IM2 = IM;
IM2(~biggestBlob) = 0;
imshow(IM2);
Thank you Image Analyst and Sean de Wolski for you kindest help and inputs!
Hi Image Analyst,
I used the code below to extract the biggest blob from other mammogram but i did not manage to get the image of the breast. Why is that so?
%------------------------------------------------------------------------------------------------
%This program illustrate the user on the steps of image segmentation and
%processing of Breast Mammogram.
%------------------------------------------------------------------------------------------------
clc; % Clear command window.
disp('Running Image Segmentation of Breast Mammography...'); % Message sent to command window.
close all; % Close all figures.
clear all; % Erase all existing variables.
workspace; % Make sure the workspace panel is showing.
fontSize = 20;
IM = imread('mdb020.pgm');
subplot(2,2,1),imshow(IM);
title('Original Image', 'FontSize', fontSize);
% Maximize the figure window.
set(gcf, 'Position', get(0, 'ScreenSize'));
axis square;
labeledImage = bwlabel(IM);
measurements = regionprops(labeledImage, 'Area');
% Get all the areas
allAreas = [measurements.Area];
[biggestArea, indexOfBiggest] = sort(allAreas, 'descend')
% Extract biggest
biggestBlob = ismember(labeledImage, indexOfBiggest(1));
% Convert to binary
biggestBlob = biggestBlob > 0;
subplot(2, 2, 2);
imshow(biggestBlob, []);
title('Final Binary Image', 'FontSize', fontSize);
axis on;
IM2 = IM;
IM2(~biggestBlob) = 0;
subplot(2, 2, 3);
imshow(IM2);
And I get the results below.
Looks like the threshold is too low so that you get a path of dark gray pixels between the breast and marker. Try raising the threshold.
binaryImage = IM > 30; % Or whatever works.
labeledImage = bwlabel(binaryImage);
There could be lot of situations that you need to handle to be completely robust. I gave a solution for one of them. Each time you add another weird situation, the algorithm will need to be modified. For example, in the above case there seems to be a dark grey path connecting the breast to the tag. So you need to handle that, say by raising the threshold so there's a break between the breast and the tag. But then that may shrink the breast in other places, which you don't want. One thing to note is that the tag's texture is not as much as the breast. So you could use a texture filter to determine what areas are breast and which are smooth background and tag. You can split apart the breast and the tag with watershed, and check if the texture inside the split blobs is smooth, meaning it's a tag, or rough, meaning it's breast. Bottom line, you may have to combine several methods to make it more robust to all the possible situations that might occur.
Okay Thank you Image Analyst for you help. I will attempt the recommended methods and select the one that best suit for this segmentation.

Sign in to comment.

Hi Image Analyst,
I have attempted your function but it eliminates the small areas and ROI the tag instead. My proposed method is to eliminate the tag and ROI the small areas. Below is my codings for review.
%------------------------------------------------------------------------------------------------
%This program illustrate the user on the steps of image segmentation and
%processing of Breast Mammogram.
%------------------------------------------------------------------------------------------------
clc; % Clear command window.
disp('Running Image Segmentation of Breast Mammography...'); % Message sent to command window.
close all; % Close all figures.
clear all; % Erase all existing variables.
workspace; % Make sure the workspace panel is showing.
fontSize = 20;
IM = imread('mdb016.pgm');
subplot(2,2,1),imshow(IM);
title('Original Image', 'FontSize', fontSize);
% Maximize the figure window.
set(gcf, 'Position', get(0, 'ScreenSize'));
axis square;
%Using histogram to adjust the image
I_eq = adapthisteq(IM);
subplot(2,2,2),imshow(I_eq);
title('Equalized Image', 'FontSize', fontSize);
%Method #1: using a thresholding method.
%Above 200(>), will appear white; Below <200, will appear black
%Remove objects in the image that is less than 250 pixels
thresholdValue = 200;
binaryImage = I_eq > thresholdValue;
%clear the border
IM_cb = imclearborder(binaryImage);
BW2 = bwareaopen(IM_cb, 250);
BW_filled = imfill(BW2, 'holes');
subplot(2,2,3),imshow(BW_filled);
title('Segmented Image', 'FontSize', fontSize);
labeledImage = bwlabel(BW_filled);
measurements = regionprops(labeledImage, 'Area');
% Get all the areas
allAreas = [measurements.Area];
[biggestArea, indexOfBiggest] = sort(allAreas, 'descend')
% Extract biggest
biggestBlob = ismember(labeledImage, indexOfBiggest(1));
% Convert to binary
biggestBlob = biggestBlob > 0;
subplot(2, 2, 4);
imshow(biggestBlob, []);
title('Final Binary Image', 'FontSize', fontSize);
axis on;
Below is the resulted image. Please kindly review my codes and advice. Thank you very much.

Community Treasure Hunt

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

Start Hunting!