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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:35:03+00:00 2026-05-26T14:35:03+00:00

I would like to do an affine transformation on a very low resolution bitmap

  • 0

I would like to do an affine transformation on a very low resolution bitmap and I would like to do it while preserving the maximum amount of information.

My input data is a 1 bit 64-by-64 pixel image of hand written character and my output would be greyscale and higher resolution. Upon analysing the image I construct a series of affine transformations (rotation, scaling, shear, translation) what I could multiply into a single affine transformation matrix.

My problem is that given the input image and my computed affine transformation matrix, how can I calculate my output image in the highest possible quality? I have read articles about different interpolation techniques, but all of them are about how to do interpolation for scaling, and not for general affine transforms.

Here is a demo what is doing exactly what I am looking for. Given an affine transformation matrix and an interpolation technique it calculates an image.

http://bigwww.epfl.ch/demo/jaffine/index.html

Can you explain me what are the steps required for calculating a higher resolution (for example 4x) greyscale image, if I have a lower resolution 1-bit input and a given T affine transformation matrix?

Can you link me to some source code or tutorials or articles or possibly even books about how to implement a linear, cubic or better interpolation with affine transform?

I need to implement this problem in Java, and I know Java has an Affine class, but I don’t know if it implements interpolation. Do you know any C++ or Java library what has nice to read code for figuring out how to write an algorithm for doing affine transform using interpolation?

Are there any freely available libraries for Java or C++ which have built-in functions for calculating affine transform using interpolation?

  • 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-05-26T14:35:03+00:00Added an answer on May 26, 2026 at 2:35 pm

    OK, here is the solution I ended up with.

    1. I transformed all my array[][] into a BufferedImage object

      static BufferedImage BImageFrom2DArray(float data[][]) {
          int width = data.length;
          int height = data[0].length;
          BufferedImage myimage = new BufferedImage(width, height,  BufferedImage.TYPE_INT_RGB);
          for (int x = 0; x < width; x++) {
              for (int y = 0; y < height; y++) {
                  int value = (int) ((1f - data[x][y]) * 255f);
                  myimage.setRGB(y, x, (value << 16) | (value << 8) | value);
              }
          }
          return myimage;
      }
      
    2. Applied the affine transformation using AffineTransformOp with interpolation bicubic

          AffineTransformOp op = new AffineTransformOp(tx, AffineTransformOp.TYPE_BICUBIC);
          BufferedImage im_transformed = op.filter(im_src, null);
      
    3. Transformed back the BufferedImage object into array[][]:

          static float[][] ArrayFromBImage(BufferedImage bimage, int width, int height) {
          int max_x = bimage.getWidth();
          int max_y = bimage.getHeight();
          float[][] array = new float[width][height];
          for (int x = 0; x < width; x++) {
              for (int y = 0; y < height; y++) {
                  float red, alpha, value;
                  int color;
                  if (x >= max_x || y >= max_y) {
                      array[y][x] = 0;
                  } else {
                      color = bimage.getRGB(x, y);
                      alpha = (color >> 24) & 0xFF;
                      red = (color >> 16) & 0xFF;
                      value = 1f - red / 255;
                      if (alpha == 0) {
                          array[y][x] = 0;
                      } else {
                          array[y][x] = value;
                      }
                  }
              }
          }
          return array;
          }
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Would like to declare data (Coord a) => Triangle a = Triangle{t0 :: a,
Would like to build the absolutepath use this information. Anyone knows how?
Would like to extract an amount in the following string: £5000 per Night -
Would like to get a list of advantages and disadvantages of using Stored Procedures.
Would like to create a strong password in C++. Any suggestions? I assume it
Would like to be able to set colors of headings and such, different font
Would like to know what a programmer should know to become a good at
Would like to make anapplication in Java that will not automatically parse parameters used
Would like to know the c# code to actually retrieve the IP type: Static
I would like to test a string containing a path to a file for

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.