# Compare ImageKeypoints of two Images?

Posted 4 years ago
3518 Views
|
|
3 Total Likes
|
 I am trying to compare two same images (with little modification in angle/brightness/ImageData) based on Feature Detection(ImageKeypoints).I have computed ImageKeypoints for imageA (get a small piece of the image for each interesting point) as: one = MapThread[ImageTrim[imageA, {#1}, 2.5 #2] &, Transpose@ ImageKeypoints[imageA, {"Position", "Scale"}, "KeypointStrength" -> .001]] and similarly for imageB: two = MapThread[ImageTrim[imageB, {#1}, 2.5 #2] &, Transpose@ ImageKeypoints[imageB, {"Position", "Scale"}, "KeypointStrength" -> .001]] Now I compare these KeyPoints, to do so I have applied perceptual hash algorithm: generateHash[img_, method_: "Average"] /; (method == "Average" || method == "pHash") := Module[{resized, grayscale, mean, imgdata, binarized}, If[method == "pHash", resized = ImageResize[img, {32, 32}], resized = ImageResize[img, {8, 8}]]; grayscale = ColorConvert[resized, "Grayscale"]; imgdata = ImageData[grayscale, "Byte"]; If[method == "pHash", imgdata = FourierDCT[imgdata]; mean = Mean@Rest@Flatten@imgdata[[;; 8, ;; 8]], mean = ImageMeasurements[grayscale, "Mean"]]; binarized = UnitStep[imgdata - mean]; IntegerString[FromDigits[Flatten@binarized, 2], 16]] compare[img1_, img2_, method_: "Average"] /; (method == "Average" || method == "pHash") := Module[{hash1, hash2}, hash1 = generateHash[img1, method]; hash2 = generateHash[img2, method]; If[StringLength@hash1 == StringLength@hash2, HammingDistance[hash1, hash2], Infinity]] similarCount=0 For[i = 1, i <= Length[one], i++, For[j = 1, j <= Length[two], j++, If[compare[one[[i]], two[[j]], "pHash"] < 11, similarCount++, continue]]] Here the compare method return the Hamming distance. If the distance is less up-to 10, I conclude they are same else different.Now the problem is all the small piece of the images for each interesting point returns Hamming distance above 10 and hence I get the result that Images are Not Same.I am new to Image Processing and guess I am doing something wrong, can you please help me figure it out or suggest some other alternative for the same!Thanks.
 Oh oh, I hope the first picture was taken after the flooded one.Are you trying to find a geometrical transformation that would align these two images so that you can measure the level of water, etc.?If so, give a shot at ImageCorrespondingPoints followed by FindGeometricTransform. ImageCorrespondingPoints knows how to compare keypoints using their "Descriptor". FindGeometricTransform assumes a geometric camera model such that it implies that all 2D keypoints in the image correspond to 3D world points that belong to the same 3D plane. Keep that in mind if your results are not satisfying. You could then using the option Masking to restrict the correspondences to 3D planes that makes sense for your pictures.In case you'd like more feedback later on, please consider posting the original pictures.