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
Solved

algorithm for resizing an image

Posted on 2004-04-02
3
2,667 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: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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Suggested Solutions

Title # Comments Views Activity
Auto-indent certain lines in Notepad++ 10 112
Help Required 3 108
VB.NET String Settings and Temp Folder Question 3 54
collection output issue 9 36
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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.
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 …
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…

860 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