Solved

algorithm for resizing an image

Posted on 2004-04-02
3
2,664 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
3 Comments
 
LVL 30

Assisted Solution

by:mayankeagle
mayankeagle 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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Add mobile access to browser application 3 133
mergeTwo  challenge 13 72
python sqlite question 11 43
C Programming - If Statement 8 51
RIA (Rich Internet Application) tools are interactive internet applications which have many of the characteristics of desktop applications. The RIA tools typically deliver output either by the way of a site-specific browser or via browser plug-in. T…
I know it’s not a new topic to discuss and it has lots of online contents already available over the net. But Then I thought it would be useful to this site’s visitors and can have online repository on vim most commonly used commands. This post h…
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

762 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now