How can we compare an encrypted number with a normal number? I am currently doing a project on privacy preserving encryption using a k-means system and the Paillier encryption algorithm (homomorphic algorithm). I have to send an image of a skin disease to the server as an encrypted image.

To do this, k-means is applied on the encrypted image and the image is sent to the respective party with k-means already applied. The decryption happens on the party side.

However in the k-means algorithm itself, I have to compare an encrypted pixel value of the image to a normal number, and this is where I am getting stuck.
If this is not performed under the encrypted version of the plaintext on the semi-honest party there is a problem.

Assume that there is a method $f(m,c)$ return $T$ if the values are same and $F$ if the values are not same. So you can compare a plaintext with a ciphertext. 

With the same way you did, an attacker can test any number to reveal the value. 

   for i in range(plaintext):
       if F(i,c):
          break


So this must be as follows;


negate the value,
encrypt it with the Paillier,
Sent it to the server.
the server calculates the summation,
the server returns the result.


If there are more than one k-means on the server, and, actually, you are trying to perform 

SELECT * FROM table WHERE key_mean = query


you need to apply a different method.