How to match rotation query image with database image?

1 visualización (últimos 30 días)
Mei Synn Tan
Mei Synn Tan el 6 de Jul. de 2017
Comentada: Image Analyst el 6 de Jul. de 2017
1. rotate 45 degree
2. rotate 90 degree
3. rotate 135 degree
4. rotate 180 degree
5. rotate 270 degree
6. rotate 315 degree
7. Database image
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;

Respuestas (1)

Image Analyst
Image Analyst el 6 de Jul. de 2017
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 comentarios
Mei Synn Tan
Mei Synn Tan el 6 de Jul. de 2017
Yes, based on CBIR, but I am not going to develop CBIR system. I just want to research and testing it. If my query image change to square shape, how I am going to match 2 images? Thanks
Image Analyst
Image Analyst el 6 de Jul. de 2017
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

Iniciar sesión para comentar.

Community Treasure Hunt

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

Start Hunting!

Translated by