How to resize an image with Rmagick crop if necessary. - ruby

I'm trying to create an image server that is riapi (https://github.com/riapi/riapi/blob/master/level-1.md) compliant.
One of the required resize modes is crop (the image will be minimally cropped evenly to match the required aspect ratio). Anyone know which of Rmagick's million methods I'm looking for?

Looks like resize_to_fill does what I was looking for. I just miss-read the documentation.

Related

Image Dimension Size in Denoising Image using CNN

I have a set of synthetically noisy images. Example is shown below:
I have also their corresponding clean text images as my ground truth data. Example below:
The dimension size of the two images is 4918 x 5856. Is it an appropriate size for training my Convolutional Neural Network that will perform image denoising. If no, what shall I do? Resize or crop? Thanks.
This resolution really is overkill. You can start off with 1/64 of the size ~(600,750), which is already pretty big.
I was facing this problem recently as well. I learned that you need to crop the image into patches, each of about 500x500. Then you need to denoise each patch and put it all together. This usually gets the most accurate results. Let me know if you need anything else!

Resize image from file to the right aspect ratio vb6

I searched about re-sizing images all over the place and they all use picturebox and Image control trying to fit an image inside it without distortion of the image.
In my case I have an image of 2048X900 of size but the image is stretched in width I need to read it from a file, repair it by changing the aspect ratio of the image, and store it back. I leaned I can't do directly on the image and some use control to do all this steps.
Any suggestion of I have to use a control to change the ratio of an image
thanks
When you choose to resize an image into a different aspect ratio than the original's, you'll need to decide how you'd like that to happen. There are various ways, like stretching (as you already mentioned), padding (resizing the image and filling the padding with whitespaces or anything else), or cropping the image (which means that you'll need to choose which parts of the images remain visible and which ones don't).
There are quite a few of ways to perform such image resizing, either locally with a software or using cloud services.
For example, with Cloudinary you can upload an image and resize it to any dimensions you'd like, including altering the aspect ratio. Everything is done seamlessly on the fly and in the cloud.
For more information:
http://cloudinary.com/documentation/image_transformations#aspect_ratio_based_cropping
Disclosure - I work at Cloudinary.

How to upscale my low res image to high res image using any software?

I have a low-res image in the attachments section, would anybody explain me technique to make it high-res image ? It would be really helpful if you could show me how can I improve resolution, quality and bring out the elements from the image clearly.
As far as I know there is no way to change the resolution upwards simply because your image lacks the data to do so. There is no program that would 'calculate' the pixels to more then there are. Ether find the source of the image and take a larger picture or have a higher resolution rendered. You could -trace- the image in illustrator and abandon the exact composition of the artwork.
I know "Vector Magic" Paid software. Give it a try.
I also suggest tracing the image in illustrator and that way you will create a new image with higher pixel counts. It is not possible to "add" any pixels in your current image as it originally does not have additional pixels.
Also, please specify if you want to improve resolution while enlarging the picture or you wish to use it as the same size? This will help in getting a to the point answer.

Blurry images in Plone Kupu

I use the Kupu editor in Plone3 to insert images in the website, automatic scaling images, and make a smaller thumb with a link to the original image.
This is a tutorial of how we do that:
http://www.contentmanagementsoftware.info/plone-book/kupu/insert-image-properties/index_html
Kupu creates a new scaled image (not only scaling with css, but scaling it for real), and the result is that images become a little blurry. I don't know if this issue is related to this document.
The question comes to my mind. Is there anybody who find this issue too? Is there any way to fix it?
I think the only way to achieve a great quality images is scaling them manually with photoshop or some graphic editor. But seems that Kupu doesn't allow to do that. You must swallow with its manners and upload its self-generated images.
Well, a bit too localized, but we find main error. I want to respond in case that any user will be in the same situation...
Kupu scale images to a certain width and height. And later, the css rescaled again a little bigger, making blurry images.
That is the main problem, we reduced an image, then enlarged it browser-side again. We didn't notice until now that there was css behind the kupu implementation and "overriding" (so to speak) our configuration.

How to check for white image backgrounds using RMagick or any other Ruby Gems?

I am trying to validate images based on few criteria:
The image should not have a border [I could accomplish to an extent using RMagick and its 'trim' method.]
The image must have a white background
The image should not contain any visible watermark.
Please let me know if you can think of any way to accomplish #2 and #3 above.
Note: I am using Ruby so any solution using Ruby or Ruby gems is appreciated.
For detecting #1 (not removing), I would read the color of every pixels along the edge and calculate the standard deviation. If it's very low or zero (and the pixels are non-white) then you have a border. Keep doing this in loops from the edge in case there is a multi-pixel-wide border.
For #2 you could look at the four corners of the image and see if they are all white (or maybe 3/4). You could, alternatively, count the number of pixels in the image that are full white and ensure that there are a large number of them.
For #3, I have no idea. You're talking about some seriously advanced image processing. A brief Google search turned up few good answers for detecting common low-opacity/blended watermarks. There are good resources for extracting your own stenography 'watermark' from an image, but I suspect that is not your goal.

Resources