There are several ways to solve this. Do you want a vector of gaps (one gap width for every column), OR the average height (which actually doesn't need you to determine the gap on a column-by-column basis believe it or not).
But make it easy for us to help you, not hard. Attach the actual image either in a PNG file or a .mat file. We don't want the screenshot with tick labels, tick marks, surrounding gray background, etc. If you give all all that junk, it makes it hard for us because we need to take several steps to get rid of them and get down to the actual image.
The only thing you don't state is what to do in the case around x=400 where white pixels do not demarcate the "top". One way to make the algorithm below work is to modify the array so that there is always white on top and bottom, as I do with C.
B = imbinarize(im2gray(imread('borderProblem.png')));
-Is the distance obtained in pixels? if yes, how can I convert it to millimeters
-I would need a code that loads a series of jpg photos (such as the binarized one) from a windows folder, which performs the code you provided me and then saves these figures to me in another folder (perhaps using the imwrite command to save the file)
Yes, in pixels. You would need some type of ruler or ground truth measurement in the frame of the image for the conversion: do you know the image dimensions in millimeters?
Hi Matt, I tried to write this code that works well enough only that in the end it fails to save the images shown on the screen(I have attached the file_2.m).
The code asks to load the input images(these are attached) taken from an input folder ,calculates the distances and then has to save the output images (shown on screen) in another output folder.
You were opening a figure, then closing all, which made h go away. (You don't necessarily need close all if you close(h) explicity, which I added below).
Use saveas when saving figures and the figure handle.
I should complete my last point of the thesis which consists in obtaining a single output graph representing the difference between n single output graphs.
Matt to be clearer, I have to write a code, even in the same script, which averages those graphs always in terms of column by column distances between those white lines (the single output graph must be similar to that of those single graphs)
Francesco, the way this forum works is that we help you with snippets of your code. If you want help, please show what code you tried using the code block formatter.
Matt, If I have about 200 images in the input folder, how can I get an average graph (plot mean),according to that cycle for,for every 10 iterations of images?
Matt,sorry if I keep bothering you but I can't solve this last point of the thesis.
I implemented that code in the script and it eventually saves me in the output folder equal images.
Always considering the same four input images that I attach to you and making average plots(plot mean) every 2 images(for example, because in reality I have to do this operation every 10 images out of 200 input images), I find 2 identical graphs in the output folder.
Could you take a look at the script I am attaching to you?
I would like to understand where I'm wrong.
Also can you check if the for loop on the average plot has been written well?
Finally I get a graph with the various distance curves and the average graph. How can I extract the average chart and plot it on another chart? What command can I use?
If you compile all of it in your main loop using all_maxDist then you just create a new figure for that variable. I would seek out some of the MATLAB tutorials on matrices and loops, this is fundamental stuff. I'm going to unsubscribe here, I think you need to start a new thread based on very specific problems you're having.
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
1 Comment
Direct link to this comment
https://ch.mathworks.com/matlabcentral/answers/719195-how-to-find-the-inner-distance-between-the-2-white-lines#comment_1268180
Direct link to this comment
https://ch.mathworks.com/matlabcentral/answers/719195-how-to-find-the-inner-distance-between-the-2-white-lines#comment_1268180
Sign in to comment.