Shifting pixel to dewarped position

조회 수: 2 (최근 30일)
Max
Max 2014년 5월 27일
편집: Matt J 2014년 5월 28일
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

채택된 답변

Matt J
Matt J 2014년 5월 27일
  댓글 수: 2
Max
Max 2014년 5월 28일
Thanking you Matt.. I read those articles.. The thing is I want a very basic methodology like interpolation.. OR probably something like I have an angle of tilt calculated ,so just something like a masked filter to rotate them on the centroid axis and lifting the pixel up or down ..
Matt J
Matt J 2014년 5월 28일
편집: Matt J 2014년 5월 28일
The warping in the figure you posted looks much more complicated than a simple tilt. You can see that the text is curved, not merely rotated. It is not even a general projective transformation.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Graphics Performance에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by