Quantifying pore size distribution for a 2-d image
Afficher commentaires plus anciens
I have an image and I need to find the pore size distribution for the image. I have a short deadline, your suggestions/comments are highly welcomed.
Réponse acceptée
Plus de réponses (1)
Image Analyst
le 6 Oct 2011
ali: Regarding your last comment requesting a code example:
clc; % Clear the command window.
workspace; % Make sure the workspace panel is showing.
fontSize = 30;
% Create sample image.
binaryImage = zeros(15,20);
binaryImage(2:3:16, 3:16) = 1
% Display it.
subplot(1,2,1);
imshow(binaryImage, []);
title('Binary Image', 'fontSize', fontSize);
set(gcf, 'units','normalized','outerposition',[0 0 1 1]);
% Label each blob so we can make measurements of it
[labeledImage numberOfRegions] = bwlabel(binaryImage, 8);
% Make up a custom colormap.
% Figure out how many colors there should be.
% It should have one more for black, which isn't given a label.
numberOfColors = numberOfRegions+1;
halfNumberOfColors = floor(numberOfColors / 2); % For green ramps.
myColorMap = zeros(numberOfColors, 3);
% Make up red component - an upward ramp.
myColorMap(:,1) = linspace(0,1,numberOfColors)';
% Make up green component: an inverted V shape.
myColorMap(1:halfNumberOfColors,2) = linspace(0,1,halfNumberOfColors)';
myColorMap(halfNumberOfColors+1:end,2) = linspace(0,1,halfNumberOfColors)';
% Make up blue component: a downward ramp.
myColorMap(:,3) = linspace(1,0, numberOfColors)';
% Print custom colormap values out to the command window.
disp(myColorMap);
% Apply the colormap to the labeled image and create a new RGB image.
coloredLabels = label2rgb (labeledImage, myColorMap, 'k');
% Display the colored image.
subplot(1,2,2);
imshow(coloredLabels, []);
caption = sprintf('Image converted to RGB\nusing Custom Colormap');
title(caption, 'fontSize', fontSize);
Catégories
En savoir plus sur Images dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!