- 20.7.1 Breast Cancer, Mammograms, Analysis, Mammography
- 20.7.1.1 Breast Cancer Cell Analysis, Pathology, Nuclei Detection
- 20.7.1.2 Mammography, Microcalcifications, Detection, Analysis
- 20.7.1.3 Mammography, Thermal, Infrared Analysis
- 20.7.1.4 Mammography, Texture Based Techniques, Wavelets
- 20.7.1.5 Mammograms, Image Enhancement, Noise Suppression
- 20.7.1.6 Mammograms, Ultrasound
- 20.7.1.7 Mammograms, Density Issues
- 20.7.1.8 Mammograms, MRI, Magnetic Resonance Imaging
- 20.7.1.9 Mammograms, Three Dimensional Analysis, Registration
How to arrange pixels for appropriate threshold
2 次查看(过去 30 天)
显示 更早的评论
I have two mammography image .
I want to segment tumor area and for this using threshold method.
But image intensities are different for every image so it affect my result badly.
I tried to calculate mean intensity of image with using "meanIntensity = mean(grayImage(:)) " and if condition statement according this value for threshold, but it doesn't work again in a right way.
I mean mdb005 image I am using threshold > 155 to get good result but for mdb013 I have to choose >210 or other values. (İf I choose >155 it shows huge for mdb013)
But if I choose >210 this time mdb005 tumor dissappear.
What to do for these two image to segment exact tumor automatically.
I used @Image Analystcodes in the past questions and combine with other codes and created this codes.
images attached
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 25;
%===============================================================================
% Get the name of the image the user wants to use.
% baseFileName = 'pat00002_1-1-1-1-2-10-1.mp4.cover.png';
baseFileName = 'mdb005.png';
% Get the full filename, with path prepended.
folder = ['C:\Users\Ali\Desktop\Miaspng']; % Determine where demo folder is (works with all versions).
fullFileName = fullfile(folder, baseFileName);
%===============================================================================
% Read in a demo image.
grayImage = imread(fullFileName);
% Get the dimensions of the image.
% numberOfColorChannels should be = 1 for a gray scale image, and 3 for an RGB color image.
[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(:, :, 2); % Take green channel.
end
% Display the image.
subplot(2, 3, 1);
imshow(grayImage, []);
axis on;
caption = sprintf('Original Gray Scale Image');
title(caption, 'FontSize', fontSize, 'Interpreter', 'None');
drawnow;
hp = impixelinfo();
% Set up figure properties:
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0 1 1]);
% Get rid of tool bar and pulldown menus that are along top of figure.
set(gcf, 'Toolbar', 'none', 'Menu', 'none');
% Give a name to the title bar.
set(gcf, 'Name', 'Demo', 'NumberTitle', 'Off')
drawnow;
meanIntensity = mean(grayImage(:))
if meanIntensity<35
mask = grayImage > 190;
elseif meanIntensity<40
mask = grayImage > 185;
elseif meanIntensity<45
mask = grayImage > 182;
elseif meanIntensity<50
mask = grayImage > 175;
elseif meanIntensity<55
mask = grayImage > 170;
elseif meanIntensity<60
mask = grayImage > 165;
elseif meanIntensity<65
mask = grayImage > 155;
elseif meanIntensity<70
mask = grayImage > 150;
end
% Display the mask image.
subplot(2, 3, 2);
imshow(mask);
axis on;
axis image; % Make sure image is not artificially stretched because of screen's aspect ratio.
title('Binary Image Mask', 'fontSize', fontSize);
drawnow;
% Find the areas
labeledImage = bwlabel(mask);
props = regionprops(labeledImage, 'Area', 'Centroid');
allAreas = sort([props.Area], 'descend');
allCentroids = [props.Centroid];
centroidsX = allCentroids(1:2:end);
centroidsY = allCentroids(2:2:end);
% Make a margin of 10% of the image size.
marginx = 0.34 * columns;
marginy = 0.15 * rows;
keepers = (centroidsX > marginx & centroidsX < (columns - marginx)) & ...
(centroidsY > marginy & centroidsY < (rows - marginy));
indexes = find(keepers);
% Get a mask with only the keepers in it
newMask = ismember(labeledImage, indexes);
% Display the mask image.
subplot(2, 3, 3);
imshow(newMask);
axis on;
axis image; % Make sure image is not artificially stretched because of screen's aspect ratio.
title('Tags Remove', 'fontSize', fontSize);
drawnow;
% Mask the gray scale image
maskedGrayImage = grayImage; % Initialize.
maskedGrayImage(~newMask) = 0;
% Display the masked grayscale image.
subplot(2, 3, 4);
imshow(maskedGrayImage);
axis on;
axis image; % Make sure image is not artificially stretched because of screen's aspect ratio.
title('Masked Gray Scale Image', 'fontSize', fontSize);
drawnow;
IM_cb = imclearborder(maskedGrayImage);
BW2 = bwareaopen(IM_cb, 150);
BW_filled = imfill(BW2, 'holes');
subplot(2, 3, 5);
% figure,
imshow(BW_filled);
axis on;
axis image; % Make sure image is not artificially stretched because of screen's aspect ratio.
title('Small Lines Eliminated', 'fontSize', fontSize);
drawnow;
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, 3, 6);
% figure,
imshow(biggestBlob, []);
axis on;
axis image; % Make sure image is not artificially stretched because of screen's aspect ratio.
title('Final', 'fontSize', fontSize);
drawnow;
0 个评论
回答(1 个)
Image Analyst
2021-5-16
Something that simplistic will rarely work. You need to use more sophisticated algorithm like given here:
Look at sections:
Find a paper you like and code it up or ask the author for code.
10 个评论
Image Analyst
2021-6-6
Sorry I can't put it on my agenda. I simply don't have enough time to code up all the interesting papers I run across. Plus I don't want to rob you of all the glory you said would come your way once you write it.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Basic Display 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!