Asked by Emily
on 21 Jun 2012

Dear all, I creat a 2-D network by method of fractal interpolation to simulate soil cracks. In my program ,plot(x,y) which plots the network , x,y stand for the points' corrdinate value. I want to compute this network's fractal dimension, but I can't get this image from the figure plotted. My quentions are how to get this image in jpg. or bmp.without white blank like the figure, and how to get the binary matrix of this figure. Thanks in advance.

Answer by Image Analyst
on 21 Jun 2012

Accepted answer

Emily, If you want an image of your cracks, first I'd create a blank image with zeros(). Then I'd go down through every x,y pair that you have using imline() to draw the line (crack) from one point to the next. Now you have your image with all your cracks on it, and you can use export_fig() to write it out to a standard format image file. This will give you just the image alone - no tick marks and titles etc.

However if you want a plot, rather than an image, I'd continue doing it the way you are and then use export_fig() to get the whole plot - including the title, x and y axis labels, tick marks, outer plot area bounding box, etc.

I don't really see how the image of the cracks is going to help you calculate the fractal dimension of the crack network though. I don't use fractals but I though the fractal dimension of a 2D image would look at all the pixel values of all the pixels to give a metric that is kind of related to the "roughness" of the image, but that wouldn't be appropriate to get the fractal dimension of a binary image of a crack network.

Emily
on 22 Jun 2012

i'm sorry i should have been clearer in my quenstion. Base on statistics of actual cracks, the stages i get the crack network are listed as follws: first, generating random dots according to the actual node density of cracks per m2; second, creating random network based on a relationship of nodes' connection; third, generating inflections between two nodes connected, calculate the corrdinate of the infections; last, according to the nodes and inflections in order, using the fractal interpolation to interpolate, then these dots formede the network. I'm stucked in the last stage, in this stage, the interpolated iterations are decided by fractal dimension of the image i get compared with the actual networks, when the the fractal dimension reaches to the actual, the iteration end, otherwise, continue. Now i don't know how to get the iterations.

Please forgive my poor English, thanks again.

Image Analyst
on 22 Jun 2012

Answer by Walter Roberson
on 21 Jun 2012

getsnap() or getframe(); and then imwrite() or saveas() or print() or use the File Exchange contribution export_fig

You can set the axes background color to something other than white.

Show 7 older comments

Walter Roberson
on 22 Jun 2012

http://www.mathworks.com/help/techdoc/ref/getframe.html

Image Analyst
on 22 Jun 2012

Answer by faraz.a
on 25 May 2013

please tell me how to create a matrix of zeroes and ones for black and white pixels of a binary image.

Image Analyst
on 25 May 2013

One way is to threshold a grayscale image

binaryImage = grayImage > thresholdValue;

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

Learn moreOpportunities for recent engineering grads.

Apply Today
## 0 Comments