Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to count a specific pixel number in "part of" image

C:\fakepath\health_bar.JPG It is easy to see the black(little transparent) part and the orange part in the image. I want to calculate the orange part pixels dynamically---as the area of orange in the bar is changing in a video.

I counted it easily with numpy like np.sum(image_np==[245,12,10]). Here [245,12,10] is one of the orange color pixel vector I detected.It is working! But problem is, sometimes the same pixel would appear in the black part,which is not easy to see for human.
I tried using Kmeans to erase the little orange pixel in the black part, but it is not working, because I realize Kmeans just clustering color without taking pixel color surrounding into account.

Then is there an approach to erase the little pixel in a image but also give results like Kmeans.

How to count a specific pixel number in "part of" image

C:\fakepath\health_bar.JPG It is easy to see the black(little transparent) part and the orange part in the image. I want to calculate the orange part pixels dynamically---as the area of orange in the bar is changing in a video.

I counted it easily with numpy like np.sum(image_np==[245,12,10]). Here [245,12,10] is one of the orange color pixel vector I detected.It is working! But problem is, sometimes the same pixel would appear in the black part,which is not easy to see for human.
I tried using Kmeans to erase the little orange pixel in the black part, but it is not working, because I realize Kmeans just clustering color without taking pixel color surrounding into account.

Then is there an approach to erase the little pixel in a image but also give results like Kmeans.

How to count a specific pixel number in "part of" image

C:\fakepath\health_bar.JPG It is easy to see the black(little transparent) part and the orange part in the image. I want to calculate the orange part pixels dynamically---as the area of orange in the bar is changing in a video.

I counted it easily with numpy like np.sum(image_np==[245,12,10]). Here [245,12,10] is one of the orange color pixel vector I detected.It is working! But problem is, sometimes the same pixel would appear in the black part,which is not easy to see for human.
I tried using Kmeans to erase the little orange pixel in the black part, but it is not working, because I realize Kmeans just clustering color without taking pixel color surrounding into account.

Then is there an approach to erase the little pixel in a image but also give results like Kmeans.

click to hide/show revision 4
None

updated 2018-10-22 03:28:19 -0600

berak gravatar image

How to count a specific pixel number in "part of" image

C:\fakepath\health_bar.JPGC:\fakepath\health_bar.JPG It is easy to see the black(little transparent) part and the orange part in the image. I want to calculate the orange part pixels dynamically---as the area of orange in the bar is changing in a video.

I counted it easily with numpy like np.sum(image_np==[245,12,10]). Here [245,12,10] is one of the orange color pixel vector I detected.It is working! But problem is, sometimes the same pixel would appear in the black part,which is not easy to see for human.
I tried using Kmeans to erase the little orange pixel in the black part, but it is not working, because I realize Kmeans just clustering color without taking pixel color surrounding into account.

Then is there an approach to erase the little pixel in a image but also give results like Kmeans.