MATLAB Answers

## How to find mean line of the this edge?

Asked by vikash kumar

### vikash kumar (view profile)

on 13 Aug 2019
Latest activity Commented on by Image Analyst

### Image Analyst (view profile)

on 17 Aug 2019
Hi,
I'm working on image processing so i need help here i uploaded my image here.What i need is to find the middle line which will the skeleton of the edge.Please help me.
Thanks.

KALYAN ACHARJYA

### KALYAN ACHARJYA (view profile)

on 14 Aug 2019
mean line means?

Sign in to comment.

## 2 Answers

Answer by Matt J

### Matt J (view profile)

on 14 Aug 2019

Try bwskel

#### 0 Comments

Sign in to comment.

### Image Analyst (view profile)

Answer by Image Analyst

### Image Analyst (view profile)

on 14 Aug 2019

Call bwareafilt() to get the largest blob:
mask = bwareafilt(mask, 1);
Then scan across column by column to get the midline
[rows, columns] = size(mask);
topLines = zeros(1, columns);
bottomLines = zeros(1, columns);
for col = 1 : columns
y = find(mask(:, col), 1, 'first');
if ~isempty(y)
topLines(col) = y
bottomLines(col) = find(mask(:, col), 1, 'last')
end
end
% Get midline
midLine = (topLines + bottomLines) / 2;
% Fit a line through it, if you want
goodColumns = topLines ~= 0;
x = 1:columns;
coefficients = polyfit(x(goodColumns), midLine(goodColumns), 1)
yFitted = polyval(coefficients, x);
hold on;
plot(x, yFitted, 'r-', 'LineWidth', 2);

vikash kumar

### vikash kumar (view profile)

on 16 Aug 2019
crop_from_image is crop from the ECG graph
BW after transfer into the binary
after_process i did
Edge_1 = edge(BW,'Canny');
J = bwmorph(Edge_1,'bridge');
J = bwmorph(J,'thicken');
J = im2uint16(J);
B = imgaussfilt(J);
J1 = bwmorph(BW,'skel');
J1 = im2uint16(J1);
B1 = imgaussfilt(J1);
add_image1 = (B+B1);
add_image2 = bwmorph3(add_image1,'fill');
add_image2 = edge(add_image2,'Canny');
after doing this i got the missing pixel then i got the edge of the outer pixel
then i put the algorithm for which I need the only one side of the edge but when i apply my algorithm it's showing like final_plot.fig which is not correct after i have to convert into the plot into the excel sheet means i have to convert scan image into the digital form.
problem with the fig also that the 3 vetical segment in between the line
Image Analyst

### Image Analyst (view profile)

on 16 Aug 2019
Darn, I was gettong all ready to help you now that I have more time, and you forgot to attach the images. Please attach the original PNG, tiff, bmp or JPG images. I can't call imread() on hte fig files.
Image Analyst

### Image Analyst (view profile)

on 17 Aug 2019
Oh, OK, so you don't really want to or need to do edge detection at all. All you need to do is to find the black lines, which you can do by color segmentation. So try that. Or better yet, just get the original digital signals if you can rather than trying to figure them out from a cell phone image of a strip chart.

Sign in to comment.