What is the resolution of an image in ImageNet dataset? - resolution

Does anyone know the resolution of an image in the ImageNet dataset?
I'm sorry, but I couldn't find it on their website or in any of the papers.

The images vary in dimensions and resolution. Many applications resize / crop all of the images to 256x256 pixels.

The average image resolution on ImageNet is 469x387 pixels. Normally it's applied a pre-processing that samples them to 256x256 as #Prune said, but it depends on the task at hand.

In a brief check of a random ImageNet 2012 folder (Fish)...
The largest image is 4288 x 2848 pixels.
The smallest image is 75 x 56 pixels.
This is representative of the aspect ratio range.

It depends of the picture but you can resize them. The smaller dimension of the picture should be at least 256 px and the aspect ratio should be intact.

224 X 224 is used by most of the networks.

There is a detailed answer to this in the following article: https://towardsdatascience.com/compression-in-the-imagenet-dataset-34c56d14d463
Essentially, most common image size is 500x500, however, there is a large distribution of image sizes. Typically, either the width or the height of an image is 500 pixels, if not both. Aspect ratios of 1:1, 4:3, 3:2 (and 3:4 and 2:3) are most common.

Related

Godot pixelated image

Godot 2d project, I created at 640 640 png using Gimp.
Imported those PNG's to Godot as texture(2d).
After setting scale to 0.1, I resized those images to 64 x 64 in godot scene.
When I initiate this image in my main scene, I get this pixelated disgusting result.
Edit : Dont be confused with rotated red wings, I did it at runtime. Its not part of the question.
My window size is 1270 x 780
Stretch Mode is viewport.
I tried changing import settings etc.
I wonder is it not possible to have a sleek image in this sizes?
Disclaimer: I haven’t bothered to fire up Godot to reproduce your problem.
I suspect you are shooting yourself in the foot by that scale 0.1 bit. Remember, every time you resample (scale) an image there is loss.
There are three things to do:
Prepare your image(s) to have the same size (resolution) as your intended target display. In other words, if your image is going to display at 64×64 pixels, then your source image should be 64×64 pixels.
When importing images, make sure that Filter is set to ☑ On. If your image contains alpha, you may also wish to check the Fix Alpha Border flag.
Perform as few resampling operations as possible to display the image. In your particular case, you are resampling it to a tenth of its size before again resampling it up to the displayed size. Don’t do that. (This is probably the main cause of your problem.) Just make your sprite have the natural size of the image, and scale the sprite only if necessary.
It is also possible that you are applying some other filter or that your renderer has a bad resampler attached to it, but your problem description does not lead me to think either of these are likely.
A warning ahead: I'm not into godot at all, but I have some experience with image resizing.
Your problem looks totally related to pure image resizing. If you scale down an image in one go by any factor smaller than 0.5 (this means make it smaller than half its original size), you will face this effect of an ugly small image.
To get a nice and smooth result, you have to resize it multiple times:
Always reduce the image size by half, until the next necessary step is bigger than scaling by 0.5.
For your case (640x640 to 64x64) it would need these steps:
640 * 0.5 => 320
320 * 0.5 => 160
160 * 0.5 => 80
80 * 0.8 => 64
You can either start with a much smaller image - if you never need it with that big size in your code, or you add multiple scaled resolutions to your resources, or you precalculate the halfed steps before you start using them and then just pick the right image to scale down by the final factor.
I'm not very experienced with godot and haven't opened it right now, but I could imagine that you shouldn't scale the image to 0.1 because then there will be a loss in image quality.

SSD Mobilenet v1 coco - Should I resize images before I label them for training?

I am using a Dell server with 2 Nvidia V100 GPUs, Ubuntu 16.04, Tensorflow 1.7.
I am trying to figure out about when to resize my images. In the ssd_mobilenet_v1_coco.config, it has
image_resizer {
fixed_shape_resizer {
height: 300
width: 300
}
}
I have drawn bounding boxes on many, many images with a total of 10 classes. The images are different sizes, some large, some small. My detection of objects is performing very poorly. I tried resizing a bunch of the images down to 300x300 then redrawing the bounding boxes, but this does not help and the images are pretty low quality and scaled incorrectly.
My question is: Do I need to scale my images to 300x300 before I label them? If I don't do that, will SSD Mobilenet do the resize and my bounding boxes will not line up or are they resized appropriately along with the images? I don't want to draw bounding boxes on large images then have them not be correct when SSD Mobilenet does the resize.
Thanks in advance.
i can't really answer to your question since i don't know how are you learning your SSD MobileNet.
I assume that you want to use your own dataset and convert it into tfrecord, right?
If so, you will have to handle the resizing on your own
If you are going to use COCO dataset, you can use pycocotools in order to create desired tfrecord
Best regards,
Vaclav

Scikit-learn, image classification

This example allows the classification of images with scikit-learn:
http://scikit-learn.org/stable/auto_examples/classification/plot_digits_classification.html
However, it is important that all the images have the same size (width and height, as written in the comments).
How can I modify this code to allow classification of images with different sizes?
You will need to define your own Feature Extraction.
In example from above, every pixel is represent a feature. If your images of different sizes, most trivial (but certainly not the best) thing that you can do is pad all images to the size of largest image with, for example, white pixels.
Here an example how to add boarders to image.

Maximum file size of JPEG image with known dimensions

I'm going to let users upload images of 300x300 compressed with JPEG. Is there a way to determine what the maximum file size of such an image would be?
I can imagine this can be tried by compressing random noise at 100 quality, but is there a theoretical maximum?
Say that the image is totally uncompressable random noise, could it be 3 bytes per pixel (24-bits colour) and a margin for the metadata? Or could such an image turn out larger than the original when compressed?
From wikipedia:
For highest quality images (Q=100), about 8.25 bits per color pixel is required
http://en.wikipedia.org/wiki/JPEG#Sample_photographs
So, for Q=100 on an 300x300 image, that would result in (300 * 300) px * 8.25 bits/px = 742,500 bits = ~ 93 kB
There are also lossless JPEG coding modes, which are practically not used (last sentence, second paragraph). But they would have the RGB typical 24 bits/pixel.
There is no limit on jpeg metadata size, which means there's no limit to the size of a jpeg file. See this answer I've linked for an explanation of why and also for an example of a realistic situation where the metadata might get large: What is the maximum size of JPEG metadata?
So if assuming a maximum practical/realistic size suits your purpose, then you should factor that example into your calculations. In many contexts it would be fine to just reject things outside of that maximum as outside the domain of your program's intended usage.
But if you absolutely must rely on theoretical, then unfortunately it's a big bold ∞
Note: I do not have a huge amount of personal experience with the jpeg specification, so I am going off of what people have said about repeated fields being allowed, as well as multiple comment fields. Please correct me if you find evidence to the contrary.

Reducing colors in a PNG image is making the file size bigger

I am using ImageMagick to programmatically reduce the size of a PNG image by reducing the colors in the image. I get the images unique-colors and divide this by 2. Then I assign this value to the -colors option as follows:
variable = unique-colors / 2
convert image.png -colors variable -depth 8
I thought this would substantially reduce the size of the image but instead it increases the images size on disk. Can anyone shed any light on this.
Thanks.
EDIT: Turns out the problem was dithering. Dithering helps your reduced color images look more like the originals but adds to the image size. To remove dithering in ImageMagick add +dither to your command.
Example
convert CandyBar.png +dither -colors 300 -depth 8 smallerCandyBar.png
Imagemagick probably uses some dithering algorithm to make image appear as though it has original amount of colors. This increases image data "randomness" (single pixels are recolored at some places to blend into other colors) and this image data no longer packs as well. Research further into how the convert command does the dithering. You can also see this effect by adding second image as a layer in gimp/equivalent program and tuning transparency.
You should use pngquant for this.
You don't need to guess number of colors, it has actual --quality setting:
pngquant --verbose --quality=70 image.png
The above will automatically choose number of colors needed to match given quality in the same scale as JPEG quality (100 = perfect, 70 = OK, 20 = awful).
pngquant has substantially better quantization algorithm, and the better the quantization the better quality/filesize ratio.
And pngquant doesn't dither areas that look good without dithering, and this avoids adding unnecessary noise/randomness to the file.
The "new" PNG's compression is not as good as the one of the original.

Resources