How can I quantify blobs in multiple images at once?
Show older comments
Hello all,
Using, color thresholding from the Image Processing Toolbox, I want to analyse the area of different blobs and calculate the total amount of blobs.
This is my script:
originalImage = uigetfile(".bmp");
originalGray = rgb2gray(originalImage);
Binary = createMask(originalImage);
labeledImage = bwlabel(Binary, 8);
Measurements = regionprops(labeledImage, originalGray, 'Area');
numberOfBlobs = size(Blobs, 1)
function [BW,maskedRGBImage] = createMask(RGB)
% Convert RGB image to chosen color space
I = RGB;
% Define thresholds for channel 1 based on histogram settings
channel1Min = 0.000;
channel1Max = 255.000;
% Define thresholds for channel 2 based on histogram settings
channel2Min = 0.000;
channel2Max = 101.000;
% Define thresholds for channel 3 based on histogram settings
channel3Min = 0.000;
channel3Max = 102.000;
% Create mask based on chosen histogram thresholds
sliderBW = (I(:,:,1) >= channel1Min ) & (I(:,:,1) <= channel1Max) & ...
(I(:,:,2) >= channel2Min ) & (I(:,:,2) <= channel2Max) & ...
(I(:,:,3) >= channel3Min ) & (I(:,:,3) <= channel3Max);
BW = sliderBW;
% Initialize output masked image based on input image.
maskedRGBImage = RGB;
% Set background pixels where BW is false to zero.
maskedRGBImage(repmat(~BW,[1 1 3])) = 0;
end
This works fine for analysing 1 image at a time, but since I have hundres of images to process, I want to change my script to handle multiple images (78) at once and - if possible - store the results in one variable.
Thank you for your time and effort!
Accepted Answer
More Answers (0)
Categories
Find more on Image Processing and Computer Vision 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!