Domanda

I'm trying to implement Naive Bayes Nearest Neighbor (NBNN) for image classification. In the algorithm it asks for the Euclidean distance between two pixels belonging to different images.

I have 1) a set of m-images in a m-by-40,000 matrix (where 40,000 is the number of pixels in one image) and 2) another set of n-images in a n-by-40,000 matrix.

1) is the training set and 2) is the validation set.

In order for me to apply NBNN, from my understanding, I need to find the Euclidean distance between each pixels of 2) to the corresponding pixels of 1).

My question is, given two grey scale values, one from 1) and the other from 2), how would I find the Euclidean distance between them in order to apply k-NN?

È stato utile?

Soluzione

Let x, y be two gray-scale 200-by-200 images. Pixels levels are x1,x2,...x40000 and y1, y2,...y40000. The euclidean distance between x and y is d(x,y)=sqrt(sum_i((xi-yi)^2))

Altri suggerimenti

I will refer to the notation and definition given at wikipedia

You have 1d-data, thus p=(p1) and q=(q1). e(p,q)=sqrt((p1-q1)^2)=abs(p1-q1)

For the 1d-case, the euclidean distance is the absolute difference of the grey values.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top