문제

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?

도움이 되었습니까?

해결책

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))

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top