Solved

algorithm for resizing an image

Posted on 2004-04-02
3
2,669 Views
Last Modified: 2007-12-19
hi

I am doing a project this year that requires to develop a program that will read an scanned image and resize it.

Upto now I have been able to extract the RGB values for each pixel in the picture using the PixelGrabber class in java but I do not know how to manipulate these values while resizing them.

The project needs to convert all scanned images to a predefined size. For example, images of size 800*600 and 200*185, both are to be converted to size 300*300.

I need the algorithm that will do my work.
0
Comment
Question by:shah1d1698
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 30

Assisted Solution

by:Mayank S
Mayank S earned 50 total points
ID: 10741390
Maybe you can try shearing:

http://www.javaalmanac.com/egs/java.awt.image/CreateTxImage.html

Also have a look at the "Related Examples".
0
 
LVL 10

Expert Comment

by:Kavar
ID: 10741403
there are several methods, they break down to drop or blend, which are you wanting?
0
 
LVL 22

Accepted Solution

by:
NovaDenizen earned 200 total points
ID: 10784359
Here's a way to do it without getting your hands dirty with individual pixels.

Image oldImage; // this is the original image you need to initialize

Image newImage = comp.createImage(300,300); // comp is some instance of java.awt.Component you have laying around
g = i.getGraphics();  // Image.getGraphics() only works on images you get from Component.createImage()
g.drawImage(oldImage, 0, 0, 300, 300, null); // you might not be able to get away with null here
g.dispose();

Now, newImage is a 300x300 version of oldImage.

If instead you're looking to do you own pixel-by-pixel resizing, you need to look into 'resampling'.  A good paper to look at is "A pixel is not a little square" at ftp://ftp.alvyray.com/Acrobat/6_Pixel.pdf.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
Progress
Starting up a Project

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question