Content-Aware Image Cropping with C# - c#

I am working on a CMS like project which users can upload images with contents. I have to create thumbnails for the uploaded images on the fly. Lets say the thumbnail size as 125x75
I can resize images without problem but when it comes to crop operation several problems occur. My resize and crop procedure works like this:
Load the original image.
Resize the image to desired size preventing the original aspect ratio depending on the given maximum width or height
If the result image has a different aspect ration than the output aspect ratio than a centered crop operation is applied.
But what I want to achive is a content-aware cropping as described in Jue Wang's article Opticrop: Content-aware Cropping with PHP and ImageMagick
Is there any way to do it with C# or is there a library that can do this operation.
Note: I do not want content-aware resizing. Content-aware resizing (seam craving) can be done with ImageResizing.net SeamCarving plugin

If you are using the ImageResizing.net framework, the WhitespaceTrimmer plugin may be a good starting point I think.
If you want to write the code yourself, this Gist shows a good solution using entropy but is written in Ruby.

Related

losing quality when resizing with ImageResizer

I'm using the ImageResizer .net library. It works as expected, but one image messes around.
I've uploaded the image below. I've already tried some things like format=jpg&quality=100, only width=220, also different sizes, but it always adds this blurry border around the image.
The original image is a png.
This one is the original image:
This one is resized by the ImageResizer:
And this one is resized with photoshop:
EDIT:
If you're running into the same issue. Try to set up the SpeedOrQuality Plugin. I've set it to speed=3 and the image is sharp again.
Vector graphics require different resampling algorithms than photographs.
ImageResizer V4 includes higher quality image resampling options under the FastScaling plugin.
For graphics (non-photographic images), I suggest playing with &f.sharpen=0..100, &down.preserve=-5..5, and &down.filter=Robidoux. Make sure &fastscale=true and FastScaling is installed.
You can certainly find a good configuration for your rasterized vector art and set up a preset for it. FastScaling is capable of much better resampling than Photoshop - on par with Lightroom, in fact.
Enabling fastscaling alone helps substantially (?width=200&fastscale=true):
Adding sharpening gives a very clear result: (?width=220&fastscale=true&f.sharpen=100):
Visibly crisper than Photoshop:
Each time you save a jpeg, you loose quality (the image is reencoded).
I would recommend using the same quality as the original image was save against, it should give the best results.
Using a higher quality is not recommended as it will artificially try to improve quality, mistaking approximations done by previous encoding for details, resulting in things like the blurry border.
Aside that, usually, one should not use a quality over 95 for jpeg encoding.

Resizing images to a fixed size

I need to resize images with multiple dimensions to same size . Those are profile images and I can crop width or height of image if needed to make aspect ratio similar . Also I need to add watermark to image . Suggest any library which is good for image manipulation.
Thanks
Image Magick is very good, has bindings to most language and is available for most operating systems - it is also free.
Here is a short list I can remember:
http://www.graphicsmill.com/
http://imageresizing.net/
http://www.atalasoft.com/products/dotimage/
http://www.coreoptical.com/
http://www.leadtools.com/
Actually your task is pretty simple so I guess most of SDKs will easily handle that. And if you don’t need any specials about .net integration, Image Magick should be good enough.

Way to auto-remove the watermark when the original watermark image is available

I have a lot of images that I created a while back, and all of them have the same watermark in the same location. I don't have the originals. I also have the original watermark image that is applied to all pictures.
I have never done this sort of thing before, are they any good approaches to this task?
Once you apply a watermark over an image, the original data of the image that gets covered by the watermark is gone forever. All you can do is use some blending and interpolation techniques to "guess" the original data. Having the original watermark helps you to identify it easier in your images. Maybe you can use the AForge .NET library to accomplish the task.

Does WPF embed full size image into output?

I have a WPF application that includes buttons with PNG images. The actual images get scaled by grid control inside the button to about 32 pixels or so (depending on button size). At the same time my original artwork created in Photoshop is 250x250 pixels in size.
Currently I create artwork in Photoshop, add it to my WPF project as a resource, and have WPF automatically scale it to the button size.
Here's my question - if my original image is 250x250 pixels, and WPF squeezes it into a button so that it is only 32x32 pixels, does my output file contain the 250x250 image, or the 32x32 image?
I'm asking because if the app performance is going to be negatively affected by the original image size, I'd rather just scale it in Photoshop myself.
Yes, it will include the full file, because it can't recognize that it might not be shown larger at runtime. You can check this by decompiling your program using ILSpy.

Zooming an extremely large image

Is there any predefined control in WPF or VS2010 to implement the Image Zooming functionality (like Googlemaps) for a bitmap displayed over a panel using C#? My bitmap will be minimum 8GB in Size.
Thanks in advance
Murali
There is DeepZoom for Silvelight. There is no such thing in WPF. It was planned for WPF4, but removed before RTM.
Update:
Loading images of this size is pretty uncommon. You should consider tiling as others suggested. Also consider if you really need load all data at once. If the image has size of for example 30000x30000 then the user do not really need/can't to see all this data. Use tiling and appropriate image format (jpg etc) for each zoom level.
Relevant links:
Single objects still limited to 2 GB in size in CLR 4.0?
Pushing the Limits of Windows: Physical Memory

Categories

Resources