How I could detect the bottom breast boundaries by using a 2nd order polynomial curve fitting algorithm to get segmented/seperated left and right breast??

1 次查看(过去 30 天)
Hi,
I would like to seperate each brest as left and right. Inferior lateral quadrant should be inclueded in its entirely regardless of breast size because the algorithm should be for different breasts and breast size. My purpose and desire is to seperate left and rigt breast automatically for bilateral asymmetry analysis.
Steps What I desire:
  • Since the breast boundaries will be parabolic in shape, a 2nd order polynomial fitting algorithm will be used to detect the bottom breast boundaries. A parabolic curve is first fitted to each object, then two curves with maximum coefficient of determination candidate for the lower breast boundaries. If the difference between x-coordinates of the lowest peaks of two curves is less than 20 and the difference of their y-coordinates is greater than 250, they are selected as lower breast boundaries (X–X ′ < 20 and Y–Y ′ > 250). Otherwise, the algorithm searched the other curves.
  • The next step is to determine the top of the breast. The region with the highest curvature in the left and right body edges will used to estimate the position of the armpit. Often, poor edge detection indicated major points of concavity elsewhere in the body edge, and the point of maximum concavity in the image was found to be lower or higher than what is expected. Besides, choosing the fitted parabola as lower breast boundaries may be lead to crop the region of the breast and cause information loss because of the poor lower breast edge in many cases.
You can see below what I desire as pic.
Detection 4 curves // Detected 4 curves of breast
Could you please help me about my problem? I'm looking forward to hearing from u. Thanks in advance.
clc; clear; close all;
a=rgb2gray(imread('DINAMIC-FRONTAL.jpg'));
en= imsharpen(a,'Radius',2,'Amount',1);
B = imgaussfilt(en,1.4);
ed=edge(B,'canny',0.3,0.5);
figure();imshow(ed);title('canny edge');
bw1=bwareaopen(ed,10);
se = strel('disk',4);
bw=imdilate(bw1,se);
figure();imshow(bw);
[y x] = find( bw );
right = find(min(a));
as=findpeaks(y);
xr = x(right);
yr = y(right);
xl = x(as);
yl = y(as);
pr = polyfit( yr, xr, 2); %// fit 2rd deg poly
pl = polyfit( yl, xl, 2 );
yy = linspace( 1, size(bw,1), 50 );
figure; imshow(a, 'border', 'tight' );
hold all
plot( polyval( pr, yy ), yy, '.-', 'LineWidth', 1 );
plot( polyval( pl, yy ), yy, '.-', 'LineWidth', 1 );

回答(2 个)

Image Analyst
Image Analyst 2021-8-4
Do they all look like that, with a bright region under the breast? If so, what I'd try is to first find the bright region and then find the upper boundary of it. Then split it in half and fit a quadratic to each top boundary. Then find the column where the quadratics cross to find the separation line between the breast. Maybe Canny will work too - I haven't tried yet because my MATLAB is busy upgrading itself to r2021a, Update #4 (check the bell icon in your upper right corner of MATLAB to see if you're due to be updated).

Image Analyst
Image Analyst 2021-8-4
Try this:
% Demo by Image Analyst.
clc; % Clear the command window.
fprintf('Beginning to run %s.m ...\n', mfilename);
close all; % Close all figures (except those of imtool.)
clearvars;
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 20;
grayImage = rgb2gray(imread('DINAMIC-FRONTAL.jpeg'));
en = imsharpen(grayImage,'Radius',2,'Amount',1);
B = imgaussfilt(en,1.4);
ed=edge(B,'canny',0.3,0.5);
subplot(2, 2, 1);
imshow(ed);
title('Initial Canny Edge', 'FontSize', fontSize);
bw1=bwareaopen(ed,10);
se = strel('disk',4);
bw=imdilate(bw1,se);
subplot(2, 2, 2);
imshow(bw);
title('Next Mask', 'FontSize', fontSize);
% Take largest 2 blobs.
bw = bwareafilt(bw, 2);
% Erase top half
[rows, columns] = size(bw);
bw(1:round(rows/2), :) = false;
% Skeletonize
bw = bwskel(bw);
% Find branchpoints.
[bpRows, bpColumns] = find(bwmorph(bw, 'branchpoints'))
% Erase branchpoints.
hold on;
for k = 1 : length(bpRows)
bw(bpRows(k), bpColumns(k)) = false;
plot(bpColumns(k), bpRows(k), 'r.', 'MarkerSize', 50);
end
% Erase any blobs with a centroid below 400.
props = regionprops(bw, 'Centroid');
xy = vertcat(props.Centroid)
% Don't keep the two with the highest centroid.
indexesToKeep = find(xy(:, 2) < 400);
% Extract all but the lowest two.
labeledImage = bwlabel(bw);
bw = ismember(labeledImage, indexesToKeep);
subplot(2, 2, 3);
imshow(bw);
axis('on', 'image');
title('Final Mask', 'FontSize', fontSize);
% Put the branchpoints back in to make each breast just one curve.
for k = 1 : length(bpRows)
bw(bpRows(k), bpColumns(k)) = true;
end
labeledImage = bwlabel(bw);
% Find the left breast curve
[yr, xr] = find(labeledImage == 1);
% Find the right breast curve
[yl, xl] = find(labeledImage == 2);
subplot(2, 2, 4);
imshow(grayImage, 'border', 'tight' );
hold all
plot(xr, yr, 'r.', 'MarkerSize', 14);
plot(xl, yl, 'y.', 'MarkerSize', 14);
% Find the midline
xMiddle = mean([max(xl), min(xr)]);
xline(xMiddle, 'Color', 'm', 'LineWidth', 4);
title('Breast Outlines Overlaid on Original Image', 'FontSize', fontSize);
g = gcf;
g.WindowState = 'maximized';
% % Bad fitting routine follows. TODO: Fix it.
% pr = polyfit(xr, yr, 2); %// fit 2rd deg poly
% pl = polyfit(xl, yl, 2 );
% yy = linspace( 1, size(bw,1), 50 );
% xFitRight = linspace(min(xr), max(xr), 50);
% xFitLeft = linspace(min(xl), max(xl), 50);
% yFitRight = polyval(pr, xFitRight);
% yFitLeft = polyval(pr, xFitLeft);
% plot(xFitRight, yFitRight, '.-', 'LineWidth', 1 );
% plot(xFitLeft, yFitLeft, '.-', 'LineWidth', 1 );
fprintf('Done running %s.m\n', mfilename);
  3 个评论
Image Analyst
Image Analyst 2021-8-5
编辑:Image Analyst 2021-8-5
Right, but you didn't initially supply us with those other images. So you'll have to adapt it. Basically I started with your Canny edge image, and that is where it seems to break down for these two images - you don't have a good starting edge image. So you need to work on that part some more to get an image like you had in the first example.
Hopefully this will give you an idea of some things you can do with image processing, and enough for you to Accept or Vote for this answer. Unfortunately I can't do it for you for all possible images. If I made it work for your new images, then another image would would come up that it would not work for and it would need to be adapted again. I can't spend the time to do that journey with you, but good luck.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Get Started with Curve Fitting Toolbox 的更多信息

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by