# How to find the inner distance between the 2 white lines

조회 수: 1(최근 30일)
Francesco Muoio 2021년 1월 17일
댓글: Francesco Muoio 2021년 1월 30일
Hi,someone can give me a hand to make a script related to the problem?
Practically ,I want to get the distance column by column from the lowest white border of the upper part to the highest white border of the lower part.
##### 댓글 수: 1표시숨기기 없음
Image Analyst 2021년 1월 17일
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.

댓글을 달려면 로그인하십시오.

### 채택된 답변

Matt Gaidica 2021년 1월 17일
편집: Matt Gaidica 2021년 1월 17일
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.
% force white on top and bottom
C = [ones(1,size(B,2));B;ones(1,size(B,2))];
maxDist = zeros(1,size(B,2));
for iCol = 1:size(B,2)
d = diff(C(:,iCol));
edgeIdxs = find(d ~= 0);
maxDist(iCol) = max(diff(edgeIdxs));
end
close all
figure;
subplot(211);
imshow(C);
subplot(212);
plot(maxDist,'k');
xlim(size(maxDist));
ylim([1,size(B,1)]);
xlabel('col');
ylabel('dist');
##### 댓글 수: 19표시숨기기 이전 댓글 수: 18
Francesco Muoio 2021년 1월 26일
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?
I do not know how to thank you!!!

댓글을 달려면 로그인하십시오.

### 추가 답변(1개)

Matt Gaidica 2021년 1월 27일
I'm not sure this is entirely correct, but you had things improperly placed.
##### 댓글 수: 6표시숨기기 이전 댓글 수: 5
Francesco Muoio 2021년 1월 30일
Thanks, I solved everything!!

댓글을 달려면 로그인하십시오.

### Community Treasure Hunt

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

Start Hunting!

Translated by