?
Solved

algorithm for resizing an image

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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Suggested Courses

765 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