Finding the histogram difference between two pictures

11 visualizzazioni (ultimi 30 giorni)
I have face recognition and the LBPH codes. I can view the histogram of the image. However, I want to compare the test and training picture with each other and make face recognition LBPH algorithm. For this, I want to calculate the difference between the Euclidean distance and the two images(test image and train image) and find the estimated picture. I can't find euclidean distance for two histogram image. Can you help me?
Performing the face recognition: In this step, the algorithm is already trained. Each histogram created is used to represent each image from the training dataset. So, given an input image, we perform the steps again for this new image and creates a histogram which represents the image.
  • So to find the image that matches the input image we just need to compare two histograms and return the image with the closest histogram.
  • We can use various approaches to compare the histograms (calculate the distance between two histograms), for example: euclidean distance, chi-square, absolute value, etc. In this example, we can use the Euclidean distance (which is quite known) based on the following formula:
The codes I have tried are as follows:

Risposte (1)

Image Analyst
Image Analyst il 6 Apr 2021
Well there are lots of ways that code could be improved, but we can't fix it because it's an image. We can't fix or run an image. Here's just a few:
You're making the common mistake of confusing 9row, column) with (x, y). Images are indexed (row, column), not (x,y). So you need to do (y, x). For example when you do imgG(i+x1, j+y1), you should really do imgG(i+y1, j+x1) since y corresponds to rows and belongs in the first dimension and x corresponds to columns and belongs in the second dimension.
Another thing is that you can use the class as an input to zeros, like zeros(rows, columns, 'uint8') rather than uint8(zeros(rows, columns));
Then you can pass the file pattern *.jpg into dir() so you can get the count easier - without doing a loop.
And of course more comments would never be a bad thing.
And not using i and j for variable names since they're the imaginary variable. Use row and column - they are much more descriptive than i and j anyway.
And finally, you can tell MATLAB preferences to not insert spaces for tabs. Mixing spaces and tabs is a bad idea - it leads to misaligned indentation as you can see. To fix code that's already messed up like that type control-a (to select all) followed by control-i (to fix the indentation).
Oh, and one more thing. You didn't really ask a question that I can see. It's more of an announcement. So people are just going to look at it and say "Hmm. Okay. I hope/presume it works, so . . . good luck with it." I mean, you really didn't ask anything. There is no sentence in your post that ends with a question mark. So anyway I hope I at least gave you a few good tips, and ...good luck.
  4 Commenti
Merve Buyukbas
Merve Buyukbas il 14 Giu 2021
I want to match the test view and the training view. The necessary steps for this are in the link.
https://towardsdatascience.com/face-recognition-how-lbph-works-90ec258c3d6b The codes for the place up to step 3 are available at https://www.programmersought.com/article/39274411945/. But I can't do steps 4 and 5 after that. I don't know how to write code to extract histograms and make face recognition happen?

Accedi per commentare.

Community Treasure Hunt

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

Start Hunting!

Translated by