Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9138581
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:16:31+00:00 2026-06-17T09:16:31+00:00

This is my code where I am reading image rectangle.jpg from /sdcard . I

  • 0

This is my code where I am reading image rectangle.jpg from /sdcard. I want to know the pixel value (normal, as well as in RGB format). What code should I use to deal with it?

package com.idag.edge;

import android.os.Bundle;
import android.os.Environment;
import android.app.Activity;
import android.util.Log;
import android.widget.TextView;

import org.opencv.android.OpenCVLoader;
import org.opencv.core.Mat;
import org.opencv.highgui.Highgui;

public class MainActivity extends Activity {  
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        try
        {
            String path=Environment.getExternalStorageDirectory().getAbsolutePath() +"/rectangle.jpg";
            Mat m=Highgui.imread(path,1); 
            Log.i("Paramenres on matrix", "height "+ m.height()+" width "+ m.width()+" total = "+m.total()+" channels " +m.channels());

            System.out.println("element at 0 0 = "+ m.row(0).col(0).nativeObj+" element at 150 150 = "+ m.row(150).col(150).nativeObj);
        }

        catch(Exception e){
            System.err.print("Error in the code");
            Log.i("Error in imread", "Error in imread");
        } 
    }

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T09:16:31+00:00Added an answer on June 17, 2026 at 9:16 am

    Mat.get(x, y) – returns an array of all the channels values at (x, y), each channel in a different place. If your image is RGB so you will get an array of [r, g, b].

    Mat.put(x, y, value) – sets the channel values at (x, y) to value.

    double[] rgb = image.get(0, 0);
    Log.i("", "red:"+rgb[0]+"green:"+rgb[1]+"blue:"+rgb[2]);
    image.put(0, 0, new double[]{255, 255, 0});//sets the pixel to yellow
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I created an image fading slideshow reading this article . The code looks like
I'm reading this code sample : And since I don't know C#, I decided
Note: This code actually codes from a tutorial book I'm reading at the moment,
I'm trying use this code to get image resolution from file bool GetImageSizeEx(const char
i was reading this code, where setRegions is called after RootViewController is released :
i am reading an excel file using this code i found over the net:
I am reading On lisp and encountered this code (I simplified it a bit).
I was reading a blog where the writer said this Code doesn’t exist unless
I'm reading Programming Perl , and I found this code snippet: sub new {
While I'm reading boost/shared_ptr.hpp, i saw this code: // generated copy constructor, destructor are

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.