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 9115497
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:26:49+00:00 2026-06-17T04:26:49+00:00

I am using Convolution Matrix for my android app for making image Emboss. i

  • 0

I am using Convolution Matrix for my android app for making image Emboss.
i have defined the class for it as:

public class ConvolutionMatrix {
public static final int SIZE = 3;

public double[][] Matrix;
public double Factor = 1;
public double Offset = 1;

public ConvolutionMatrix(int size) {
    Matrix = new double[size][size];
}

public void setAll(double value) {
    for (int x = 0; x < SIZE; ++x) {
        for (int y = 0; y < SIZE; ++y) {
            Matrix[x][y] = value;
        }
    }
}

public void applyConfig(double[][] config) {
    for (int x = 0; x < SIZE; ++x) {
        for (int y = 0; y < SIZE; ++y) {
            Matrix[x][y] = config[x][y];
        }
    }
}

public static Bitmap computeConvolution3x3(Bitmap src,
        ConvolutionMatrix matrix) {
    int width = src.getWidth();
    int height = src.getHeight();
    Bitmap result = Bitmap.createBitmap(width, height, src.getConfig());

    int A, R, G, B;
    int sumR, sumG, sumB;
    int[][] pixels = new int[SIZE][SIZE];

    for (int y = 0; y < height - 2; ++y) {
        for (int x = 0; x < width - 2; ++x) {

            // get pixel matrix
            for (int i = 0; i < SIZE; ++i) {
                for (int j = 0; j < SIZE; ++j) {
                    pixels[i][j] = src.getPixel(x + i, y + j);
                }
            }

            // get alpha of center pixel
            A = Color.alpha(pixels[1][1]);

            // init color sum
            sumR = sumG = sumB = 0;

            // get sum of RGB on matrix
            for (int i = 0; i < SIZE; ++i) {
                for (int j = 0; j < SIZE; ++j) {
                    sumR += (Color.red(pixels[i][j]) * matrix.Matrix[i][j]);
                    sumG += (Color.green(pixels[i][j]) * matrix.Matrix[i][j]);
                    sumB += (Color.blue(pixels[i][j]) * matrix.Matrix[i][j]);
                }
            }

            // get final Red
            R = (int) (sumR / matrix.Factor + matrix.Offset);
            if (R < 0) {
                R = 0;
            } else if (R > 255) {
                R = 255;
            }

            // get final Green
            G = (int) (sumG / matrix.Factor + matrix.Offset);
            if (G < 0) {
                G = 0;
            } else if (G > 255) {
                G = 255;
            }

            // get final Blue
            B = (int) (sumB / matrix.Factor + matrix.Offset);
            if (B < 0) {
                B = 0;
            } else if (B > 255) {
                B = 255;
            }

            // apply new pixel
            result.setPixel(x + 1, y + 1, Color.argb(A, R, G, B));
        }
    }

    // final image
    return result;
}

}

It is giving me proper result but it takes too much time for calculating the result. Is there any way to make calculation faster and work efficiently?

  • 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-17T04:26:51+00:00Added an answer on June 17, 2026 at 4:26 am

    Take a look at: Convolution Demo. It is an App, which compares a convolution implementation done in Java vs in C++.
    Needless to say C++ variant runs more than 10x faster.

    So if you want speed either implement it via NDK or via Shaders.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a function which calculates image texture (using 2D convolution via NLFILTER): y=imagetexture(image,winsize)
I have written a code for the Convolution of image using API's clCreateImage2D for
I have sample image processing code which applies a convolution filter over an image
I'm using a convolution matrix for sharpness in PHP GD and I want to
I have one function to compute convolution (to test whether we are using correct
i'm writing a C# class to perform 2D separable convolution using integers to obtain
I've been using the image convolution function from Nvidia Performance Primitives (NPP) . However,
im using the following code to calculate convolution of an image with a specified
Using ember 1.0.0-pre3 I have a little app that has this code: window.App =
Using a CSS image sprite, I'm creating an 'interactive' image where hovering over certain

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.