Breast Density in Mammography

21 views (last 30 days)
João Mendes
João Mendes on 28 Mar 2021
Commented: idris on 12 Nov 2025 at 1:55
Hi to all,
Does anyone knows of any app/code to classify mammograms in density terms? Or even an app that computes a density value.
I do not want to retrieve a segmentation, only a classification or a single final value.
Thank you!

Answers (1)

Aastha
Aastha on 18 Jun 2025
I understand your objective is to regress a density value from a mammogram image. You may consider the following steps to accomplish this using a Convolutional Neural Network (CNN) in MATLAB:
1. Begin by preparing your dataset, where the input data consists of mammogram images and the corresponding target values are the associated density values. Store the image files in a folder and create a datastore or table that links each image to its label.
imageFolder = 'path_to_images';
imds = imageDatastore(imageFolder, 'FileExtensions', '.png', 'LabelSource', 'foldernames');
% Assuming labels are stored in a separate table or array
load('densityLabels.mat'); % Contains variable `densityValues`
tbl = table(imds.Files, densityValues, 'VariableNames', {'Image', 'Density'});
2. Next, define the CNN architecture using a layers array. The network should be structured for a regression task. You may use the following MATLAB code snippet for reference:
layers = [
imageInputLayer([M N 1])
convolution2dLayer(3,8,Padding="same")
batchNormalizationLayer
reluLayer
fullyConnectedLayer(numResponses)
];
3. Configure the training process by specifying training options with the "trainingOptions" function. Then, train the CNN model using the "trainnet" function. Choose an appropriate loss function for your regression task as per your requirements.
For more information on the functions mentioned above, you may refer to the following documentation pages:
I hope this helps!
  1 Comment
idris
idris on 12 Nov 2025 at 1:55
Hi Mendes!
If you're looking to classify mammograms by breast density (without segmentation), you can build a solution in MATLAB using pretrained CNNs like ResNet or DenseNet. Just extract features from the whole image and train a classifier (e.g., SVM or softmax layer) to predict BI-RADS density categories or a continuous score.
🛠️ Key steps:
  • Preprocess mammograms (resize, normalize)
  • Use activations() to extract deep features
  • Train a classifier with fitcecoc() or trainNetwork()
  • Output a single class label or density value
No segmentation needed: just whole-image classification. Let me know if you want sample code or dataset suggestions!

Sign in to comment.

Categories

Find more on Biotech and Pharmaceutical in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!