Ask Your Question

Finding sum of all pixel values of a gray image

asked 2015-12-02 00:48:49 -0500

VPallavi gravatar image

I want to find the sum of all pixel values of a gray image(Mat type). For that i need to access each pixel's intensity value. How can I do this in java? I'm using opencv library with it. In OpenCV we can use the following code:

for(int j=r.y;j<(r.y+r.height);j++)
      for (int i=r.x;i<(r.x+r.width);i++)
         int d=<uchar>(j,i);

Please suggest a solution to code it in java. Thanks!! I have tried it by using "Raster" as follows:

Raster raster = Gray_image.getRaster();

but I'm getting following error: The method getRaster() is undefined for the type Mat

Please help me!!

edit retag flag offensive close merge delete


in c++you can use mean

LBerger gravatar imageLBerger ( 2015-12-02 01:14:14 -0500 )edit

I need to find in java.

VPallavi gravatar imageVPallavi ( 2015-12-02 01:18:20 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2015-12-02 01:25:17 -0500

berak gravatar image

(the docs are your friend !)

edit flag offensive delete link more


Eduardo gravatar imageEduardo ( 2015-12-02 03:17:31 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2015-12-02 00:48:49 -0500

Seen: 5,416 times

Last updated: Dec 02 '15