[Tutor] Error in get pixel value in coordinate (x, y) using getPixel(x, y)

Steven D'Aprano steve at pearwood.info
Fri Aug 8 16:25:32 CEST 2014


On Thu, Aug 07, 2014 at 06:49:02PM +0700, Whees Northbee wrote:
> Please help me... I'm using python 2.7.6, numpy 1.8.1, opencv 2.4.9..
> I want to get pixel value in one number like 255 not each value like these
> R(190), G(23), B(45) from coordinate (x,y)...
> I try these code
> m_samples[k][i][j]=getPixel(img,row,col)
> 
> But get error:
> NameError: name 'getPixel' is not defined
> 
> If I change the format become:
> m_samples[k][i][j]=img.getPixel(row,col)
> 
> Still error:
> AttributeError: 'numpy.ndarray' object has no attribute 'getpixel'
> 
> Please help me..

We cannot help you unless you help us. Where does getPixel come from? 
What does the documentation for it say?

getPixel is not a built-in Python function, and I don't believe it is a 
standard numpy or opencv function (although I could be wrong). So unless 
you tell us where getPixel comes from, we have no possible way of 
telling how to use it.


-- 
Steven


More information about the Tutor mailing list