190 likes | 328 Views
[Image Similarity Based on Histogram]. Wang wan 581 Project Prof. Longin Jan Latecki. Image Similarity. Pixel based Histogram based Shape similarity Etc. (3, 8, 5). What is histogram?. Image Histogram. If f :[1, n]x[1, m] [0, 255] is a gray value image,
E N D
[Image Similarity Based on Histogram] Wang wan581 ProjectProf. Longin Jan Latecki
Image Similarity • Pixel based • Histogram based • Shape similarity • Etc.
(3, 8, 5) What is histogram?
Image Histogram • If f:[1, n]x[1, m] [0, 255] is a gray value image, then H(f): [0, 255] [0, n*m] is its histogram, where H(f)(k) is the number of pixels (i, j)such that f(i, j)=k • If f is a RGB image. then we compute Hr(f),Hg(f),Hb(f) seperately • Example
Hg Hr
Real Process • Read and resize all the images into 4-D array ims. • Use imhist to compute histograms • Compute the difference of 2 images using the formulas • Display the compare_order graph
Display the compare_order graph • using function sort and plot for k=1:filenum imk=ims(:,:,:,k); res(1,k)=imdiff1(imi,imk,bins); res(2,k)=imdiff2(imi,imk,bins); res(3,k)=imdiff3(imi,imk,bins); res(4,k)=imdiff4(imi,imk,bins); res(5,k)=imdiff4(imi,imk,bins); end; for method_k = 1:5 [y,ind(method_k,:)]=sort(res(method_k,:)); for file_k = 1:filenum ord(method_k,ind(method_k,file_k))=file_k; end; figure; end; figure; for k = 1:5 subplot(2,3,k); plot(ord(k,:)); title(strcat('method ',int2str(k))); end;
Formulas: a,b are two images (1) (2) (3) For gray-value image , (1) and (3) get the same result. For rgb image, they are a little different.
(4) statistic formula For pixel_based, this formula get best result. For hist_based, this formula get worst result.(for hist_based method,
Let v(a) be a vector of all c(a,x,y) values assigned to all pixels in the image a. Image similarity can be expressed as normalized inner products of such vectors. Since it yields maximum values for equal frames, a possible disparity measure is (5)
Image Database Used • Database1: • Consists of 100 images. • 100 shots taken from four different movies • Images 1-40 : Mr. Bean's Christmas • Images 41-70: Shots from House Tour • Images 71:90: Shots of squares on a desk • Images 91:100: Shots from a Kylie Minogue interview
Database2: • Consists of 30 images. • Images 0-9 are images of rose • Images 10-19 are images with red objects other than rose • Images 20-25 are ocean scenes • Image 26-29 are images of tiger • Database3: • Consists of 10 images. • Images 0-4: image of ocean scenes. in fact, they are same image with different rotating angles • Images 5-6: other images of ocean scenes
Result & Analysis • 1. Hist_based image similarity costs much less time than pixel_based imge similarity. Suppose the width of image is w, height is h. Suppose we compute the histgram of the image into m bins For every formula, if the time costs are O(n), then hist_based costs O(m), pixel_based costs O(w*h). In practice, when we compute the pic_set1 with formula (1): w=80, h=112, m=30; time of pixel_based method: O(80288600) time of hist_based method: O(900)
2. Bins of histogram can be less than 255. If we divide the histogram into 50 pins, the result is almost the same as we divide the histogram into 255 bins. We can even divide the histogram into 20 pins, the result is much the same. It doesn’t mean that the higher the number of bin is,the better result is. • 3. For Pixel_based image similarity test In gerneal, the formula (4) get the best result. The most typical case is in pic_set3, it get result as good as hist_based methods. The formula (5) get the worst result. (4)>(3),(1)>(2)>(5) • 4. For hist_based image similarity test In gerneal, the formula (4) get the worst result. (3),(1)>(5) >(2) >(4)
5. In pic_set1 and pic_set3, hist_based methods get better result than pixel_based methods. Conclusion: when different pictures have the same objects but different motion/ position, the hist_based method is better than pixel_based methods. • 6. In pic_set2, pixel _based methods get better result than hist_based methods. Conclusion: when different pictures have different objects with the same color, in general , hist_based is worse than the pixel_based methods