Ask Your Question
0

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= gray_image.at<uchar>(j,i);
         sum+=d;
      }
    }

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

Comments

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
1

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

berak gravatar image

http://docs.opencv.org/java/3.0.0/org...

(the docs are your friend !)

edit flag offensive delete link more

Comments

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

Question Tools

1 follower

Stats

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

Seen: 5,416 times

Last updated: Dec 02 '15