Allegro.cc - Online Community

Allegro.cc Forums » Off-Topic Ordeals » Image Manipulation (Enlargement)

This thread is locked; no one can reply to it. rss feed Print
Image Manipulation (Enlargement)
ngiacomelli
Member #5,114
October 2004

I've got a couple of old photographs that I'd like to digitally enlarge. I was wondering if anyone knows of any good techniques or software that will let me enlarge the image while keeping it (relatively) free of blur. I'm not looking for a major size increase.

I've got Photoshop and that usually does a nice job, but I just wanted to ask about any special software you guys may know about.

Mr. Big
Member #6,196
September 2005

I think there's no way to scale an image without blurring it.
Configurate Photoshop to use bicubic filtering and then scale it.
I don't see other options. (All the image manupulation software I know has linear and bicubic filtering.)

Richard Phipps
Member #1,632
November 2001
avatar

There are some programs out there which can use several routines to enlarge images. Although I don't think there is one magic routine here..

Try searching for Lanczos.

Steve Terry
Member #1,989
March 2002
avatar

I thought they had pills for that ;D

___________________________________
[ Facebook ]
Microsoft is not the Borg collective. The Borg collective has got proper networking. - planetspace.de
Bill Gates is in fact Shawn Hargreaves' ßî+çh. - Gideon Weems

miran
Member #2,407
June 2002

Haha, I knew this would someday be useful: http://www.cambridgeincolour.com/tutorials/digital-photo-enlargement.htm

There's specialized software available for specifically for enlarging photographs that does a very good job. According to the above linked page "GenuineFractals" is the best one. Bicubic and Lanczos and similar are general purpose algorithms that do reasonably well for all types of images but aren't really that good for any one particular type.

--
sig used to be here

Number Six
Member #3,912
October 2003
avatar

Quote:

I thought they had pills for that ;D

They Do! I was running for the toilet every 5 minutes all day and night it was terrible

---------------------------------------
By Hook or by Crook.... We WILL!

GullRaDriel
Member #3,861
September 2003
avatar

Just use allegro and stretch_blit it, or use a vector approach and blit it point/point onto a new bitmap.

It is just a few code lines.

example: EDIT: TESTED and working OK

1#include <allegro.h>
2 
3BITMAP *loaded, *new_one;
4 
5int W=0,H=0, /* new_one bitmap size */
6 x=0,y=0; /* iterators */
7
8char new_name[512];
9 
10int main( int argc , char *argv[] ){
11 
12if( argc < 2 )
13return -1; /* no parameter */
14 
15set_color_depth( 32 );
16 
17allegro_init();
18 
19loaded = load_bitmap( argv[1] , NULL );
20 
21if( !loaded )
22return -1; /* invalid filename or corrupted bitmap */
23 
24printf( "\nX Size is: %d , Enter new X size:" , loaded -> w );
25 
26scanf( "%d" , &W );
27 
28printf( "\nY Size is: %d , Enter new Y size:" , loaded -> h );
29 
30 
31scanf( "%d" , &H );
32 
33if( W <= 0 || H <= 0 )
34return -1; /* out of range values */
35 
36new_one = create_bitmap( W , H );
37 
38if( !new_one )
39return -1; /* error creating */
40 
41clear( new_one );
42 
43for( x = 0 ; x < W ; x ++ ){
44for( y = 0 ; y < H ; y ++ ){
45putpixel( new_one , x , y , getpixel( loaded , (x * loaded -> w ) / W , (y * loaded -> h) / H ) );
46}
47}
48 
49sprintf( new_name , "new_%s" , argv[1] );
50 
51save_bmp( new_name , new_one , NULL );
52 
53destroy_bitmap( new_one );
54destroy_bitmap( loaded );
55 
56allegro_exit();
57 
58}END_OF_MAIN();


Attached is a windows binary.

Usage is: test.exe name_of_bitmap_to_modify.bmp

After what you enter the new X and Y size and it will save your bitmap.

It just quit if any error occur.

EDIT2: Do not use it with /path/bitmap_name.bmp, because in this case it will try to save it under new_/path/bitmap_name.bmp.

_

"Code is like shit - it only smells if it is not yours"
Allegro Wiki, full of examples and articles !!

miran
Member #2,407
June 2002

Gulldrididi: Did you read the page I posted a link to? There are so many methods that are infinitely better than simple scaling, that your post isn't even funny anymore...

--
sig used to be here

Richard Phipps
Member #1,632
November 2001
avatar

For once.. (sigh).. I have to agree with Miran.

GullRaDriel
Member #3,861
September 2003
avatar

The OP was wanting to keep his picture free of blur. It's done by the way I gave. My post was not made to be funny. And please spell my name correctly, or just call me Gull :-/

And yeah, I have already read the whole link you gave before posting. As I said, I just give my way because of the need of non-blurred picture. If he have a sprite to enlarge and if he do not want a pink halo around it, he should not use any interpolation.

Finally, I was thinking that posting a few line of code can not be that bad.

M.Phipps, are you sure that you are not agreeing just for the sake of it ? hum hum.
_

"Code is like shit - it only smells if it is not yours"
Allegro Wiki, full of examples and articles !!

miran
Member #2,407
June 2002

Sorry for not knowing how to spell your name, but it's just so nonsensical... :P

Quote:

And yeah, I have already read the whole link you gave before posting. As I said, I just give my way because of the need of non-blurred picture.

But did you look at the sample pictures? There's a direct comparison between your method and several others (you need to hover the mouse over the links so the pictures update!) The specialized fractal/vector algorithms do not produce blur and look by far better than the pixelized look of simple scaling.

Quote:

If he have a sprite to enlarge and if he do not want a pink halo around it, he should not use any interpolation.

He has a few old photographs ::) And if he did want to enlarge sprites, the other methods are still better. Just look at that breakout game Phipps made a while ago...

Quote:

Finally, I was thinking that posting a few line of code can not be that bad.

This is certainly a good thing. :)

--
sig used to be here

GullRaDriel
Member #3,861
September 2003
avatar

Now, it is a classified story/case ;-)

"Code is like shit - it only smells if it is not yours"
Allegro Wiki, full of examples and articles !!

Richard Phipps
Member #1,632
November 2001
avatar

Simple pixel resize looks horrible unless the output size is an exact multiple (i.e. x2, x3, x4). Even then it doesn't look good for photographs.

Johan Halmén
Member #1,550
September 2001

Using some bilinear or bicubic interpolation when enlarging shouldn't be called blurring, even though the result looks kind of blurred, compared to nearest neighbour methods (allegro stretch_blit()). Blurring is what you add to a picture, when you don't change the seize. And when you blur, you lose information, when you just want to smoothen some sharp details. You may use stretch_blit() and then you may blur, but you might not end up in same result.

Take a 1024*768 image (digital photo) and scale it down to 256*192. Then make one copy that you scale back to 1024*768 using some bicubic interpolation. Make another copy using "non blurring" stretch_blit(). The former is definitely more near the original. That's why it is stupid to talk about blurring when upscaling using bicubic interpolation.

If your old photograps are on photo paper, use the best scanner you can get. Hopefully you can turn the whole issue into a downscaling issue. If they are digital images, you have to stick with the stuff on the page Miran linked to.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Years of thorough research have revealed that the red "x" that closes a window, really isn't red, but white on red background.

Years of thorough research have revealed that what people find beautiful about the Mandelbrot set is not the set itself, but all the rest.

Go to: