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

The Archive Base Latest Questions

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

I write an image filter in Matlab and I want to translate it to

  • 0

I write an image filter in Matlab and I want to translate it to java in order to use my android application. How can I convert short or int to uint8 data format.

BTW:I know there is no type like uint8 in java.

Any help will be greatly appreciated.

Matlab:

for iX = 1:imageX
    for iY = 1:imageY
        x(1:3) = input(iX,iY,:);
        output(iX, iY, :) = uint8(p1.*x.^5 + p2.*x.^4 + p3.*x.^3 + p4.*x.^2 + p5.*x + p6);
    end
end

Java:

for (int iX = 0; iX < width; iX++) {
            for (int iY = 0; iY < height; iY++) {
                Arrays.fill(x, bitmap.getPixel(iX, iY));
                short total = 0;
                for (int i = 0; i < 3; i++) {
                    total +=p1[i] * Math.pow(x[i], 5) + p2[i]
                            * Math.pow(x[i], 4) + p3[i] * Math.pow(x[i], 3)
                            + p4[i] * Math.pow(x[i], 2) + p5[i] * x[i] + p6[i];
                }
                output.setPixel(iX, iY, total);
            }
        }
  • 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-17T12:19:50+00:00Added an answer on June 17, 2026 at 12:19 pm

    Don’t create total. In matlab you handle each color component separately. Do same in java:

    for (int iX = 0; iX < width; iX++) {
            for (int iY = 0; iY < height; iY++) {
                Arrays.fill(x, bitmap.getPixel(iX, iY));
                // Result color components.
                int[] res = new int[3];
                short total = 0;
                for (int i = 0; i < 3; i++) {
                    res[i] = p1[i] * Math.pow(x[i], 5) + p2[i]
                            * Math.pow(x[i], 4) + p3[i] * Math.pow(x[i], 3)
                            + p4[i] * Math.pow(x[i], 2) + p5[i] * x[i] + p6[i];
                    // Make sure final value is in range [0, 255]
                    res[i] = Math.min(255, Math.max(0, res[i]));
                }
                output.setPixel(iX, iY, Color.rgb(res[0], res[1], res[2]);
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using WIC (Windows Imaging Component) in my WPF application to read/write image
If I write something like this: var img = $(new Image()).attr('src', image.src); How can
in my application, I need to apply a blur-filter to an image. However, the
When writing a new Core Image filter, you need to write the kernel in
I need to write and algorithm that can detect which state an application (used
I want to write a point filter that is based on the red, green
want to add hue filter in iPhone app I want to write a code
I want to convert image to grayscale on canvas by using Kinetic.js. So I
I write an image processing app that needs to do multiple things and it
I'm trying to write an image to disk: NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);

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.