Finding Distance Between Lines

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.

Antworten (2)

Image Analyst
Image Analyst am 21 Jan. 2015

1 Stimme

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 Kommentare

Cy
Cy am 21 Jan. 2015
Image Analyst, Thanks for your response. I appreciate you taking the time to help me out. How would I go about finding the horizontal and vertical pixel count from line to line? Can I count the pixels from the edge of one line to the next or would I have to count the pixels from the center of the line to the center of the next line?
Image Analyst
Image Analyst am 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
Cy am 22 Jan. 2015
Forgive me for being ignorant, as this is quite new to me. I ran your code and obtained the attached profile. I cannot seem to connect the dots with what you suggested. Perhaps I am just missing something. I apologize for the necessary "hand holding," but I would like to wrap my head around what is happening.
Image Analyst
Image Analyst am 22 Jan. 2015
Bearbeitet: Image Analyst am 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?
Cy
Cy am 22 Jan. 2015
Bearbeitet: Cy am 22 Jan. 2015
Yes, I have access to the Signal Processing Toolbox. From the findpeaks() functions, do I just need to find the maximum values from peak to peak in order to find the distance?

Melden Sie sich an, um zu kommentieren.

sukuchha shrestha
sukuchha shrestha am 22 Jan. 2015

0 Stimmen

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

Gefragt:

Cy
am 21 Jan. 2015

Bearbeitet:

Cy
am 22 Jan. 2015

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by