Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

To resolve issues starting MATLAB on Mac OS X 10.10 (Yosemite) visit: http://www.mathworks.com/matlabcentral/answers/159016

2D Mask of a 3D image

Asked by Andy on 17 Jan 2013

Hey there,

I'm rather new to using Matlab and my boss has asked me to analyze some SEM images of several membranes to compare the porosity and pore size of various membranes. The images I was given to analyze are 3D black and white images that I'd like to import into Matlab to further analyze. Ideally I'd like to be able to utilize the threshold of the image to identify the depth and thus the volume of the membrane being studied to further characterize the pores but that could be further down the road. My main question is what is the best way to create a 2D mask of the surface layer/cross-section of the image in Matlab? Also, I'd be more than happy to email a sample image if that will help clarify anything. Thanks again.

Sample Photo: https://dl.dropbox.com/u/95356349/3-009-HT-1%20T4.jpg

Andy

1 Answer

Answer by Image Analyst on 17 Jan 2013
Accepted answer

Like you said, use the threshold to identify regions of interest:

binaryImage = oneSlice > thresholdValue;

Then call do further processing or call regionprops().

13 Comments

Andy on 20 Jan 2013

Thank you very much. I'm extremely appreciative for all of your feedback and guidance. Just to clarify because I'm away from a machine with Matlab at the moment. Is imageArray a function of matlab or is that simply notation that I would replace with my image array being manipulated? For instance would the following notation be correct?

I=imread('filepath'); % load image & set threshold
thresholdValue=.90
imageArray(I<thresholdValue)=0; % Set to black
Image Analyst on 20 Jan 2013

No, not quite - you still have imageArray in there. imageArray is the name of your variable - like the (poorly-named) I in your code. If you have a typical uint8 image, the value would go between 0 and 255. So the code would be:

grayImage = imread(filepath); % Load image 
thresholdValue= 128; % Set threshold value to whatever you want
% Get map of where image is less than the threshold
binaryImage = grayImage < thresholdValue;
% Set pixels meeting threshold criteria to black (zeros).
grayImage (binaryImage) = 0; % Set to black

For the above, I inserted an extra step of creating a binary image to let you see where the image is above or below the threshold. You can imshow(binaryImage) if you want to see what pixels are affected.

Andy on 20 Jan 2013

Thank you very much.

Image Analyst

Contact us