Finding Distance Between Lines
Show older comments
Hi All, I am trying to learn how to process images in Matlab. I am trying to find the horizontal/vertical distance from the outer edge of the major gridline to other outer edge of the major gridline. The major gridlines are spaced 1" apart. I have attached some graph paper for visualization. I have a few questions as to how to start the process. Do I need to convert the image to binary in order to find the edges? How would I determine the exact edge of the gridline? How can I get the count of the pixels between these two edges?
Any guidance would be greatly appreciated to get me started in the right direction.
Thanks!
Added a PNG file.
Answers (2)
Image Analyst
on 21 Jan 2015
Get profiles and look at full width at half max
verticalProfile = sum(grayImage, 2);
horizontalProfile = sum(grayImage, 1);
subplot(2,1,1);
plot(verticalProfile);
subplot(2,1,2);
plot(horizontalProfile);
5 Comments
Cy
on 21 Jan 2015
Image Analyst
on 22 Jan 2015
Did you try what I said? I can't really try it since you put your image into a PDF document instead of uploading the image file itself. Just look at the profile and use find() to find out where it exceeds half the max value and subtract the indexes. I think it will be obvious once you see the plots.
Cy
on 22 Jan 2015
Image Analyst
on 22 Jan 2015
Edited: Image Analyst
on 22 Jan 2015
I'll look at it later this morning. In the meantime, do you have a PNG, BMP, or TIFF file? JPG files are not good for image analysis because of the jpeg artifacts like block artifacts and blurring. It's easier to go from center to center - you can use findpeaks() in the Signal Processing Toolbox. Is that okay? Do you have that toolbox?
sukuchha shrestha
on 22 Jan 2015
0 votes
use thresholding to get major grid lines run with horizontal line structuring element to get vertical major grids ( imgV) run with vertical line structuring element to get horizonal major grids(imgH) label imgV and get minX, minY for every blobs compute distance ( x-x)2+(y-y)2
Categories
Find more on Descriptive Statistics in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!