필터 지우기
필터 지우기

how to connect the adjacent lower edges of each bounding box

조회 수: 2 (최근 30일)
praveen rai
praveen rai 2019년 8월 14일
편집: praveen rai 2019년 8월 17일
I have drawn a bounding box of rectangle shape on each character and save the all 4 point of all bounding box
Now I want to connect the lower edges of bounding box with each other
How to do it??
sample code for making bounding box and saving all 4 points of bounding box
I = imread('textlineImage.png');
I=im2bw(I);
I=imcomplement(I);
st=regionprops(I,'BoundingBox','Area');
allBB = zeros(length(st), 4);
for k = 1 : length(st)
thisBB = st(k).BoundingBox;
rectangle('Position', [thisBB(1),thisBB(2),thisBB(3),thisBB(4)],...
'EdgeColor', 'r', 'LineWidth', 1)
allBB(k, :) = thisBB;
points are save in varibale allBB
Image is
234.jpg
  댓글 수: 8
Rik
Rik 2019년 8월 17일
You have the coordinates right? Then what exactly is your issue?
praveen rai
praveen rai 2019년 8월 17일
ya I have 4 point values of rectangle box in variable allBB but which two points I have to take and how to plot for every line so that I can get spline that is the issue
I am unable to wirte these thing in loop

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

답변 (1개)

Image Analyst
Image Analyst 2019년 8월 17일
편집: Image Analyst 2019년 8월 17일
Use kmeans on the y values to identify boxes in one of the 5 lines that your image has.
[classIndexes, classCentroid] = kmeans(y, 5);
After that, you know which line each y is in then sort by x, then use spline. Something like (untested)
y = allBB(2:4:end);
[classIndexes, classCentroid] = kmeans(y, 5);
newXSamplePoints = 1 : size(yourImage, 2)
for k = 1 : 5
thisClass = classIndexes(k);
thesex = sort(x(thisClass), 'ascend');
% Fit the x to splines at every column in the image.
newY = spline(x, y, newXSamplePoints);
end
hold on;
plot(newXSamplePoints, newY, 'm-', 'LineWidth', 2)
  댓글 수: 1
praveen rai
praveen rai 2019년 8월 17일
편집: praveen rai 2019년 8월 17일
its showing the following error
Error using kmeans (line 247)
X must have more rows than the number of clusters.
Error in rawcode (line 25)
[classIndexes, classCentroid] = kmeans(y, 5);
allBB has value 208*4 double and y has 1*208 double

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

카테고리

Help CenterFile Exchange에서 Axis Labels에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by