how to find the angle
1 次查看(过去 30 天)
显示 更早的评论
hai ..i wanna find the angle per every pixel in my picture,i wanna find the good feature extraction for my final project, and i think if i can find the angle every pixel in that picture i will have the best feature extraction,,,,
after thinning my picture size is 18x1000,and my last job is how to find the angle every pixel in column,,,,
in column 1,i have the bottomest pixel 1 is in coordinat(10,1)-->(row,column) and in column2 i found the bottomest pixel 1 is in coordinat (15,2)(row,column)...if i want find the angle i just make it to atan(-1/5) ..and then angle column 2 to 3,column 3 to 4,column 4 to 5 ,,,,this step will looping until column 1000... the problem is, i can't make the code who can make all the answer become 1 variabel ,,example angle_toral=[30,49,........10)..can any body help me ..?i use this code :
clear clc close all
%================gambar garis lurus 1 ================================== %====== garis lurus 1
baca= imread('straight1.bmp');
figure('name','Baca Image');
imshow(baca);
%-------------------------------------------
%-------noise removing------
h = fspecial('gaussian', [12, 12], 5);
bacanoise= imfilter(baca,h,'symmetric','conv');
figure('name','noise');
imshow(bacanoise);
%---------------------------
%------binarization--------------------------
%convert to grayscale image
bacagray = rgb2gray(bacanoise);
%convert to binary
bacabw = im2bw(bacagray,graythresh(bacagray));
%---------------------------------------------
%-----edge detection--------------------------
bacaedge = edge(uint8(bacabw),'canny');
figure('name','edge Detection');
imshow(bacaedge);
%---------------------------
Iskel = bwmorph(bacaedge,'skel',Inf)
%%******************
[baris kolom] = size(Iskel);
for kolom1=1:kolom
for baris1=1:baris
if Iskel(baris1,kolom1)==1
rightcolumn=kolom1;
end
end
end
for kolom2=kolom:-1:1
for baris2=1:baris
if Iskel(baris2,kolom2)==1
left_column=kolom2;
end
end
end
for baris3=1:baris
for kolom3=1:kolom
if Iskel(baris3,kolom3)==1
bottomest=baris3;
end
end
end
for baris4=baris:-1:1
for kolom4=1:kolom
if Iskel(baris4,kolom4)==1
highest=baris4;
end
end
end
height=((bottomest-highest))
width=((rightcolumn-left_column))
Gamcrop_lurus1awal = imcrop(Iskel,[left_column highest width
height]);%%position vector, [xmin ymin width height].
figure,imshow (Gamcrop_lurus1awal), title ('Citra setelah proses Crop');
[bariss kolomm]=size(Gamcrop_lurus1awal)
Gamcrop_lurus1=imresize(Gamcrop_lurus1awal,[(bariss) ,1000]);
figure,imshow (Gamcrop_lurus1), title ('Citra tulisan canny resize');
==================================find the angle per column-----------------
[row column] = size(Gamcrop_lurus1)
%============ segmen 1 dari column 1-2 ==================================
for kolom1segmen1=1:2
for baris1segmen1=1:row
if Gamcrop_lurus1(baris1segmen1,kolom1segmen1)==1
right_column_segmen1=kolom1segmen1;
right_row_segmen1=baris1segmen1;
end
end
end
for kolom2segmen1=2:-1:1
for baris2segmen1=1:row
if Gamcrop_lurus1(baris2segmen1,kolom2segmen1)==1
left_colum_segmen1=kolom2segmen1;
left_row_segmen1=baris2segmen1;
end
end
end
xy1segmen1=[left_row_segmen1,left_colum_segmen1];
xy2segmen1=[right_row_segmen1,right_column_segmen1];
hasilsegmen1=(xy2segmen1-xy1segmen1);
tetasegmen1start=hasilsegmen1(1,1)/hasilsegmen1(1,2);
if right_row_segmen1==left_row_segmen1
tetasegmen1 = 0
else
tetasegmen1=tetasegmen1start
end
anglesegmen1=atan(tetasegmen1)
anglesegmen1=((nilaiderajatsegmen1/pi)*180)
4 个评论
Image Analyst
2013-3-21
The non-English words also make it difficult to me since I don't speak your language. By the way, are you ever going to look at your other question that I spent time writing code for you? I don't know if I wasted my time there (and thus, might waste my time here also) because you never responded. If it worked, mark it as Accepted.
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Convert Image Type 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!