Shifting pixel to dewarped position
2 次查看(过去 30 天)
显示 更早的评论
Hi ,I am attaching a text image which i need to dewarp.. I have written codes till now to convert the image to binary , dilate it to find the words in it. Also i used the regionprops to find the centroid, orientation of the words. . The problem I am facing is next step is to go for interpolation to shift the pixels to dewarped position. I am unable to do that . Here are my codes
close all
clear all
clc
I=imread('sc2.png');
grid on
imagesc(I)
lev=graythresh(I);
ibw=im2bw(I,lev);
imshow(ibw);
xx=size(ibw);
for i=1:xx(1)
for j=1:xx(2)
if ibw(i,j)==0
ibw(i,j)=1;
else if ibw(i,j)==1
ibw(i,j)=0;
end
end
end
end
figure,imshow(ibw);
se = strel('line',4,0);
bw2 = imdilate(ibw,se);
bw2=bwareaopen(bw2,170);
figure,
imagesc(bw2), title('Original'); hold on
grid on
stats=regionprops(bw2,'BoundingBox','Centroid','Extrema','Orientation');
for object =1:length(stats)
bb = stats(object).BoundingBox;
bc = stats(object).Centroid;
be=stats(object).Extrema;
bo=stats(object).Orientation
bo;
xmin=min(be(:,1));
xmax=max(be(:,1));
ymax=max(be(:,2));
ymin=min(be(:,2));
width=max(be(:,1))-min(be(:,1));
height=max(be(:,2))-min(be(:,2));
be=round(be);
a1=be(4,:);
b1=be(7,:);
del_y=a1(2)-b1(2);
del_x=a1(1)-b1(1);
ang_deg=atan2(del_y,del_x)*180/pi; % to find the angle of orientation of words
r(object)=ang_deg
plot(bo,'-m+')
a=text(bc(1),bc(2),strcat('Ang :',num2str(round(bo))))
set(a, 'FontName', 'Arial', 'FontWeight', 'bold', 'FontSize', 10, 'Color', 'green');
end
Also the angle of orientation of the words are not accurate in some words as i saw in results.. The rest of the process i need just guidance. Thanking you
0 个评论
采纳的回答
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!