Hi,
Is there a way to get the same effect when scaling an image as when using .NET's Interpolation mode "HighQualityBilinear" (e.g. http://msdn.microsoft.com/en-us/library ... nmode.aspx)? Obviously, -interpolate bilinear is not enough.
Thanks,
Yoav
.NET "HighQualityBilinear" interpolation
-
- Posts: 5
- Joined: 2012-05-02T04:25:35-07:00
- Authentication code: 13
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: .NET "HighQualityBilinear" interpolation
Are you doing magnification or minification?yoav.gonen wrote:Hi,
Is there a way to get the same effect when scaling an image as when using .NET's Interpolation mode "HighQualityBilinear" (e.g. http://msdn.microsoft.com/en-us/library ... nmode.aspx)? Obviously, -interpolate bilinear is not enough.
Thanks,
Yoav
There are lots of options for -filter rather than -interpolate, especially if you are minifying. The default is actually better than -filter triangle (which is the equivalent of bilinear).
see
http://www.imagemagick.org/Usage/resize/
and type
convert -list filter
to get a quick list of filter options.
-
- Posts: 5
- Joined: 2012-05-02T04:25:35-07:00
- Authentication code: 13
Re: .NET "HighQualityBilinear" interpolation
Hi,
Thanks for the reply. I'm doing small magnifications on large files (say, from 10800px to 11500px width).
No matter what filter I use (and maybe I'm not using them correctly), I can't seem to get the same effect that I get when using .NET. The code is simple:
// Bitmap src is load from a file or some other source
Bitmap dst = new Bitmap(dstWidth, dstHeight);
Graphics g = Graphics.FromImage((Image)dst);
g.InterpolationMode = InterpolationMode.HighQualityBilinear;
g.DrawImage(src, 0, 0, dstWidth, dstHeight);
dst.Save(...);
// cleanup, Dispose etc.
The docs say on this interpolation mode, "Specifies high-quality, bilinear interpolation. Prefiltering is performed to ensure high-quality shrinking." This is pretty vague. I was wondering if anyone knows what it actually means, and how I can emulate it in IM. It's not really a matter of quality, the images are not necessarily photos. I'd just like to replace the .NET code with IM without changing the results.
Thanks,
Yoav
Thanks for the reply. I'm doing small magnifications on large files (say, from 10800px to 11500px width).
No matter what filter I use (and maybe I'm not using them correctly), I can't seem to get the same effect that I get when using .NET. The code is simple:
// Bitmap src is load from a file or some other source
Bitmap dst = new Bitmap(dstWidth, dstHeight);
Graphics g = Graphics.FromImage((Image)dst);
g.InterpolationMode = InterpolationMode.HighQualityBilinear;
g.DrawImage(src, 0, 0, dstWidth, dstHeight);
dst.Save(...);
// cleanup, Dispose etc.
The docs say on this interpolation mode, "Specifies high-quality, bilinear interpolation. Prefiltering is performed to ensure high-quality shrinking." This is pretty vague. I was wondering if anyone knows what it actually means, and how I can emulate it in IM. It's not really a matter of quality, the images are not necessarily photos. I'd just like to replace the .NET code with IM without changing the results.
Thanks,
Yoav
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: .NET "HighQualityBilinear" interpolation
Unfortunately, I am not expert on interpolation vs filter. But if the issue is that Photoshop results are sharper than IM, that is because they add some unsharp masking behind the scenes to their resampling process. So you can try to use IM -unsharp along with your -interpolate bilinear. You might also add -filter point before or after the -interpolate and see if that helps. My experience doubling an image in size is that adding -filter point -interplate bilinear is slightly sharper that just -interpolate bilinear alone.
see
http://www.imagemagick.org/Usage/resize/#resize_unsharp
http://www.imagemagick.org/Usage/resize/#photoshop
Anthony can explain much better than I the use of -interpolate and -filter in IM. He is the expert.
see
http://www.imagemagick.org/Usage/resize/#resize_unsharp
http://www.imagemagick.org/Usage/resize/#photoshop
Anthony can explain much better than I the use of -interpolate and -filter in IM. He is the expert.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: .NET "HighQualityBilinear" interpolation
P.S. You can actually get a sharper image when resizing using -filter catrom -distort resize. see viewtopic.php?f=1&t=20992&start=165#p88014
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: .NET "HighQualityBilinear" interpolation
Sorry for late replay -- work and private life is very busy...
All they are doing is interpolation. A operator was added recently called -interpolative-resize
This is a resize but only using the current interpolation method (not a full filter), default is bilinear.
However bilinear interpolation and triangle filter are still the same thing on magnification (different on minification).
Other differences may be an old issue of just how the edge pixels should be handled on the resize. That is, on the new size is the edge of the old the same as new (as IM does it) or is it making center of edge pixels of old, the center of edge pixels on new (to try and avoid other edge effects).
Similarly distort uses a -virtual pixel setting to determine how edge resampling should be performed. This means 'virtual pixel transparent' will make distort images fade properly to transparency.
While -resize however actually removes any sample outside the image boundary from the resampling filter. making quite a hard sharper edge! That only really works for orthogonally sacled images (IE resize, not general distortion).
-distort resize does a lot of fancy tricks to make it handle virtual pixels as resize does (ignore them want sampling source image).
All they are doing is interpolation. A operator was added recently called -interpolative-resize
This is a resize but only using the current interpolation method (not a full filter), default is bilinear.
However bilinear interpolation and triangle filter are still the same thing on magnification (different on minification).
Other differences may be an old issue of just how the edge pixels should be handled on the resize. That is, on the new size is the edge of the old the same as new (as IM does it) or is it making center of edge pixels of old, the center of edge pixels on new (to try and avoid other edge effects).
Similarly distort uses a -virtual pixel setting to determine how edge resampling should be performed. This means 'virtual pixel transparent' will make distort images fade properly to transparency.
While -resize however actually removes any sample outside the image boundary from the resampling filter. making quite a hard sharper edge! That only really works for orthogonally sacled images (IE resize, not general distortion).
-distort resize does a lot of fancy tricks to make it handle virtual pixels as resize does (ignore them want sampling source image).
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: .NET "HighQualityBilinear" interpolation
Es bleibt dabei. Wenn du für deine Joomla Webseite - unabhängig davon, ob du jetzt die 2.5 Version oder doch die 3.0 Templates nutzt, ein passendes Design haben willst, kommst du um Homepages für kostenlose oder auch kostenpflichtige Joomla 2.5 Templates nicht herum. Wordpress ist nämlich auch nicht besser, vor allen Dingen dann nicht, wenn du schnell eine externe Festplatte kaufen willst. Da war ich total aufgeschmissen, denn jeder externe Festplatte Test wollte mir das gleiche erzählen! So ein Quatsch, ich habe dann letztendlich selbst einen Festplatten Test genutzt. Schau dir die Blogs doch mal an:
externe Festplatten Test
Festplatten Test 2014
Test externe Festplatten
externe Festplatten Test
Festplatten Test 2014
Test externe Festplatten