Upscaling algo discussion
Upscaling algo discussion
Hi ImageMagick team,
First I present myself, quickly I do photograph and sometimes I print my picture; sizes can be up to 90x60cm. I discover ImageMagick just by chance. The first times I printed my picture I wasn't satisfied of the result after upscaling; then I looked for algorithms to upscale and google led me to ImageMagick.
Your soft gives good results. Filters like Mitchell and Lanczos work well but inevitably there are side-effects; side-effects are well represented by the map (http://www.imagemagick.org/Usage/img_di ... survey.gif) with aliasing/blocking/ringing/blurring.
I'm here because I'm also a software developer and I made my own implementation of the Directional Cubic Convolution Interpolation*
The result on the edge is quite good but I dislike the painty-look on the smooth part of the image; so I prefer to apply a classic bicubic on the smooth part.
You can download the corresponding archive (photoprocessor.zip) here: http://www.fraktales.net/logiciel/ which hosts my java application.
Or if you prefer I will add some examples.
This algorithm seems better because the dcci interpolation is done after (a quick) analysis of the image while a filter applies the same rule irregardless of the characteristic of the image.
I searched on the forum and I didn't see a topic discussing of this.
Finally I wrote this to ask you two questions, are you interested by this kind of upscaling ? and if yes, can I contribute to ImageMagick by adding this feature ?
Pascal
PS : Sorry for my english; please tell me if you don't understand something
* wikipedia link: https://en.wikipedia.org/wiki/Direction ... erpolation
First I present myself, quickly I do photograph and sometimes I print my picture; sizes can be up to 90x60cm. I discover ImageMagick just by chance. The first times I printed my picture I wasn't satisfied of the result after upscaling; then I looked for algorithms to upscale and google led me to ImageMagick.
Your soft gives good results. Filters like Mitchell and Lanczos work well but inevitably there are side-effects; side-effects are well represented by the map (http://www.imagemagick.org/Usage/img_di ... survey.gif) with aliasing/blocking/ringing/blurring.
I'm here because I'm also a software developer and I made my own implementation of the Directional Cubic Convolution Interpolation*
The result on the edge is quite good but I dislike the painty-look on the smooth part of the image; so I prefer to apply a classic bicubic on the smooth part.
You can download the corresponding archive (photoprocessor.zip) here: http://www.fraktales.net/logiciel/ which hosts my java application.
Or if you prefer I will add some examples.
This algorithm seems better because the dcci interpolation is done after (a quick) analysis of the image while a filter applies the same rule irregardless of the characteristic of the image.
I searched on the forum and I didn't see a topic discussing of this.
Finally I wrote this to ask you two questions, are you interested by this kind of upscaling ? and if yes, can I contribute to ImageMagick by adding this feature ?
Pascal
PS : Sorry for my english; please tell me if you don't understand something
* wikipedia link: https://en.wikipedia.org/wiki/Direction ... erpolation
Where all men think alike, no one thinks very much. (Walter Lippmann)
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Upscaling algo discussion
There has been some interest in this by other users and one of the IM developers is looking into this as time permits. We have been looking at the same Wikipedia link and also
http://www.ijarcce.com/upload/2013/dece ... ent_of.pdf
Imagemagick is coded in C. Is your code C or can you convert it to C?
I will forward this topic to the Imagemagick developer who is looking into this. He can reply in more detail.
http://www.ijarcce.com/upload/2013/dece ... ent_of.pdf
Imagemagick is coded in C. Is your code C or can you convert it to C?
I will forward this topic to the Imagemagick developer who is looking into this. He can reply in more detail.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Upscaling algo discussion
The ICBI results seem very impressive. I'd love to see this or similar in ImageMagick.
snibgo's IM pages: im.snibgo.com
Re: Upscaling algo discussion
Hello fmw42,
The upscaler is implemented using Java; indeed I can convert it to C. I have to work deeper on the implementation because my current code is far from optimal (CPU and memory usage); but optimization can be done later
I will have a look on the MagickWand C API in order to do a relevant conversion
@snibgo, yes results are quite good.
The upscaler is implemented using Java; indeed I can convert it to C. I have to work deeper on the implementation because my current code is far from optimal (CPU and memory usage); but optimization can be done later
I will have a look on the MagickWand C API in order to do a relevant conversion
@snibgo, yes results are quite good.
Where all men think alike, no one thinks very much. (Walter Lippmann)
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Upscaling algo discussion
I have forwarded this topic to the Imagemagick developer. I expect he will respond or contact you when he has the time. He may be out of town right now.
Re: Upscaling algo discussion
Ok, fine !
Where all men think alike, no one thinks very much. (Walter Lippmann)
Re: Upscaling algo discussion
Hello, I added four sample pictures in order to show how my implementation performs upscaling:
- http://www.fraktales.net/photoprocessor ... money.html
- http://www.fraktales.net/photoprocessor ... _lena.html
- http://www.fraktales.net/photoprocessor ... ctive.html
- http://www.fraktales.net/photoprocessor ... amena.html
- http://www.fraktales.net/photoprocessor ... money.html
- http://www.fraktales.net/photoprocessor ... _lena.html
- http://www.fraktales.net/photoprocessor ... ctive.html
- http://www.fraktales.net/photoprocessor ... amena.html
Where all men think alike, no one thinks very much. (Walter Lippmann)
Re: Upscaling algo discussion
Have you reviewed http://www.imagemagick.org/Usage/filter ... upsampling? If not, compare DCCI to his upsampling examples. If DCCI compares favorably, a basic version of the algorithm that works on a grayscale image in C would be useful. The C code would not rely on ImageMagick. Instead, we would port your C source to ImageMagick to support DCCI in a future release of ImageMagick.
Re: Upscaling algo discussion
Below image samples 4x upsampled using my method and Sigmoidized version of Lanczos.
Where all men think alike, no one thinks very much. (Walter Lippmann)
Re: Upscaling algo discussion
Hello magick,
The C code is now available, see http://www.fraktales.net/photoprocessor/source/
Upsample is performed by the applyDiamondUpscale function.
The border processing is not managed; I let you decide what to do in the border area of the image.
Application has been tested with 128x128 bitmap samples (cma128x128.bin, wizard128x128.bin) which contain a raw copy of the unsigned char array (no header).
The C code is now available, see http://www.fraktales.net/photoprocessor/source/
Upsample is performed by the applyDiamondUpscale function.
Code: Select all
inputs:
- width/height dimensions of the input image.
- bitmap greyscale image represented by an array of unsigned char.
- threshold value (%) used by edge detection.
output:
- greyscale image represented by an array of unsigned char.
output width = 2 * width, output height = 2 * height
byte* applyDiamondUpscale(int width, int height, byte* bitmap, byte threshold)
Application has been tested with 128x128 bitmap samples (cma128x128.bin, wizard128x128.bin) which contain a raw copy of the unsigned char array (no header).
Where all men think alike, no one thinks very much. (Walter Lippmann)
Re: Upscaling algo discussion
Thanks for the source code, it will be quite helpful in implementing the algorithm in ImageMagick. We'll look toward implementing the algorithm over the next month or so.
Re: Upscaling algo discussion
Ok, I'm glad to make my contribution to ImageMagick and I will keep watching this topic in case you need something.
Where all men think alike, no one thinks very much. (Walter Lippmann)
Re: Upscaling algo discussion
Is the algorithm restricted to 2X upscaling? Does it not support arbitrary upscaling? Instead of 128x128 upscaling to 256x256, could the algorithm instead upscale to 400x400, as an example? If so, can you update the code base to support arbitrary widths and heights?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Upscaling algo discussion
Sorry, I may not be the best judge of this, but to my eyes, I do not see a significant improvement over the sigmoid approach. The only place that seems better in your method is in the dark green lines on the object in the upper right side of the first example. Am I missing other regions that are noticeably better?
Can you post your input images?
Did you implement https://en.wikipedia.org/wiki/Direction ... erpolation? If not, do you have a reference to what you implemented and did you try to implement from that link?
Have you seen:
http://www.ijarcce.com/upload/2013/dece ... ent_of.pdf
http://www.andreagiachetti.it/icbi/ (see links to code)
Those results look much more improved than standard upscaling using bicubics. Can and would you be interested in implementing the ICBI code?
Re: Upscaling algo discussion
Hello magick,magick wrote: ↑2017-06-12T18:09:55-07:00 Is the algorithm restricted to 2X upscaling? Does it not support arbitrary upscaling? Instead of 128x128 upscaling to 256x256, could the algorithm instead upscale to 400x400, as an example? If so, can you update the code base to support arbitrary widths and heights?
This upscaling method is restricted to double the image dimensions. If you want to get a 400x400 from a 128x128 one you have to combine this algorithm with another one.
Hello fmw42,fmw42 wrote: ↑2017-06-12T19:05:03-07:00 Sorry, I may not be the best judge of this, but to my eyes, I do not see a significant improvement over the sigmoid approach. The only place that seems better in your method is in the dark green lines on the object in the upper right side of the first example. Am I missing other regions that are noticeably better?
Can you post your input images?
Did you implement https://en.wikipedia.org/wiki/Direction ... erpolation? If not, do you have a reference to what you implemented and did you try to implement from that link?
Have you seen:
http://www.ijarcce.com/upload/2013/dece ... ent_of.pdf
http://www.andreagiachetti.it/icbi/ (see links to code)
Those results look much more improved than standard upscaling using bicubics. Can and would you be interested in implementing the ICBI code?
I will highlight the part I prefer over the Sigmoid approach, but globally I think the sigmoid approach seems more aliased and more blurred than the algorithm I proposed.
Like I said in my first post, I did not implement exactly the algorithm described in the wikipedia because of too much paintly look of the image after upscale. I still use the gradient for edge detection but in the smooth part I prefer to stay to "classic bicubic" and for the second part of the method (finding horizontal/vertical lines) I prefer restrict the search on origin pixels and discard the previously computed diagonal ones:
- Square: original pixels
- Disc: previously interpolated pixels
The pixel right the original one might be interpolated across the horizontal segment of four pixels.
The pixel bottom the original one might be interpolated across the vertical segment of four pixels.
But I had a look on ICBI and I admit this is very good; so I should go deeper into this...
Thanks for your interest, I will come back to you with new elements to go forward.
Where all men think alike, no one thinks very much. (Walter Lippmann)