How to match rotation query image with database image?
1 回表示 (過去 30 日間)
古いコメントを表示
1. rotate 45 degree
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/165797/image.png)
2. rotate 90 degree
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/165799/image.png)
3. rotate 135 degree
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/165800/image.png)
4. rotate 180 degree
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/165802/image.png)
5. rotate 270 degree
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/165803/image.png)
6. rotate 315 degree
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/165804/image.png)
7. Database image
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/165810/image.png)
My question is how to match any rotation query image with database image and get the E_distance as 0? When the read the query image and detect how much degree its rotate, Database image also followed by the query image rotation and then contrast 2 image?
My code:
rgb_image = imread('13100 45 degree.png');
[x y z] = size(rgb_image);
load('colormaps.mat');
image=im2double(rgb_image);
hmmdimage=rgb2hmmd(image);
map = hmmdmap32;
hist1= zeros([1 size(map, 1)]);
hmmdimage=rgb2ind(hmmdimage,map);
for i = 1:x
for j = 1:y
gotten = zeros([size(map, 1) 1]);
for i2 = 1:8
for j2 = 1:8
if (i + i2 <= x && j + j2 <= y)
gotten(hmmdimage(i+i2, j+j2) + 1) = 1;
end
end
end
for g = 1:size(map,1)
if (gotten(g) == 1)
hist1(g) = hist1(g) + 1;
end
end
end
end
hist1=hist1/sum(hist1)
rgb_image2 = imread('13100.png');
[x y z] = size(rgb_image2);
load('colormaps.mat');
image3=im2double(rgb_image2);
hmmdimage3=rgb2hmmd(image3);
map = hmmdmap32;
hist = zeros([1 size(map, 1)]);
hmmdimage3=rgb2ind(hmmdimage3,map);
for i = 1:x
for j = 1:y
gotten = zeros([size(map, 1) 1]);
for i2 = 1:8
for j2 = 1:8
if (i + i2 <= x && j + j2 <= y)
gotten(hmmdimage3(i+i2, j+j2) + 1) = 1;
end
end
end
for g = 1:size(map,1)
if (gotten(g) == 1)
hist(g) = hist(g) + 1;
end
end
end
end
hist=hist/sum(hist)
tic;
E_distance = sqrt(sum((hist1-hist).^2))*0.5;
E_distance
toc;
0 件のコメント
回答 (1 件)
Image Analyst
2017 年 7 月 6 日
It's not so easy. The image is not simply rotated. Because images must be rectangular, white color is rotated in, so you're going to be comparing white to non-white and that will mess up your comparison. I suspect what you really want to do is CBIR where you get all images from your database that are the same type of flower. Microsoft Research has done this and you can find an overview here: https://www.microsoft.com/en-us/research/blog/researchers-team-up-with-chinese-botanists-on-machine-learning-flower-recognition-project/
2 件のコメント
Image Analyst
2017 年 7 月 6 日
Like I said, you can look at the link I gave you. Or you can research CBIR methods. Or you can look at Hu's moments : http://www.youtube.com/watch?v=Nc06tlZAv_Q
Or you can search the Image Processing Literature: http://www.visionbib.com/bibliography/contents.html
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!