Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

algorithm for resizing an image

Posted on 2004-04-02
3
Medium Priority
?
2,672 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 200 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 800 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
Make the most of your online learning experience.
Six Sigma Control Plans
Introduction to Processes

604 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