In Image Restoration problem, (still image not video image), why Peak Signal-to-Noise Ratio (PSNR) should not be more than 50 or 55 dB? I got 63 dB and they say it is wrong. why and How it is wrong?
If your pixels are represented using 8 bits per sample, the maximum possible pixel value of the image is 255. 20*log10(255) = 48 dB the mean squared error (MSE) of noise is not considered yet. The typical compression ratio of jpeg is no less than 7. In that case the MSE is around 0.224, and the corresponding PSNR is 54 dB. So you probably will not get the PSNR as high as 63 dB.
Related
From Arch Wiki:
For Xft.dpi, using integer multiples of 96 usually works best, e.g. 192 for 200% scaling.
I know that 200%, 300%,... scaling is the best possible because every pixel replaced with integer amount of pixels and we don't have situation where we need to display 1.5 pixels.
But what if don't have 4k monitor, and have for example 2.5k(2560x1440) monitor or monitor with some non-standard resolution or aspect ratio. In this case increasing scale factor 2 times is too much.
I have only 2 ideas:
Scale it in 1.25, 1.5, 1.75, so objects with 16x16 and 32x32 size will be properly scaled.
Scale it in (vertical_pixels*horizontal_pixels)/(1920*1080)*96, so you will get size of objects similar to normal display.
This is all of the information I was provided in the practice question. I am trying to figure out how to calculate it when prompted to do so on an exam...
How to determine the number of bytes necessary to store an uncompressed grayscale image of size 8000 × 3400 pixels?
I am also curious how the calculation changes if the image is a compressed binary image.
"I am trying to figure out how to calculate it when prompted to do so on an exam."
There are 8 bits to make 1 byte, so once you know how many bits-per-pixel (bpp) you have, this is a very simple calculation.
For 8 bits per pixel greyscale, just multiply the width by the height.
8000 * 3400 = 27200000 bytes.
For 1 bit per pixel black&white, multiply the width by the height and then divide by 8.
(8000 * 3400) / 8 = 3400000 bytes.
It's critical that the image is uncompressed, and that there's no padding at the end of each raster line. Otherwise the count will be off.
The first thing to work out is how many pixels you have. That is easy, it is just the width of the image multiplied by the height:
N = w * h
So, in your case:
N = 8000 * 3400 = 27200000 pixels
Next, in general you need to work out how many samples (S) you have at each of those 27200000 pixel locations in the image. That depends on the type of the image:
if the image is greyscale, you will have a single grey value at each location, so S=1
if the image is greyscale and has transparency as well, you will have a grey value plus a transparency (alpha) value at each location, so S=2
if the image is colour, you will have three samples for each pixel - one Red sample, one Green sample and one Blue sample, so S=3
if the image is colour and has transparency as well, you will get the 3 RGB values plus a transparency (alpha) value for each pixel, so S=4
there are others, but let's not get too complicated
The final piece of the jigsaw is how big each sample is, or how much storage it takes, i.e. the bytes per sample (B).
8-bit data takes 1 byte per sample, so B=1
16-bit data takes 2 bytes per sample, so B=2
32-bit floating point or integer data take 4 bytes per sample, so B=4
there are others, but let's not get too complicated
So, the actual answer for an uncompressed greyscale image is:
storage required = w * h * S * B
and in your specific case:
storage required = 8000 * 3400 * 1 * 1 = 27200000 bytes
If the image were compressed, the only thing you should hope and expect is that it takes less storage. The actual amount required will depend on:
how repetitive/predictable the image is - the more predictable the image is, in general, the better it will compress
how many colours the image contains - fewer colours generally means better compression
which image file format you require (PNG, JPEG, TIFF, GIF)
which compression algorithm you use (RLE, LZW, DCT)
how long you are prepared to wait for compression and decompression - the longer you can wait, the better you can compress in general
what losses/inaccuracies you are prepared to tolerate to save space - if you are prepared to accept a lower quality version of your image, you can get a smaller file
I'm writing a tool to detect images on our website that should be flagged for manual intervention to reduce file size. If a "large" image is 100K that might be fine, but if a "small" image is 100K, someone forgot to flatten it or compress it.
I'm looking at the "file density" of an image as the ratio filesize/(height x width). Is there a term for this? Is there some guidance about what a reasonable range for this density should be, so that I can flag images? Or am I thinking about this wrong?
Yes, if the file size is given in bits, then that fraction is known as the bitrate in bits per pixel (bpp) - as sascha points out. For example, an uncompressed image is usually 24 bit (8bit/channel * 3 channels (r,g,b)). Anything at this or higher bitrates is (most often) not compressed.
In general, lossless compression can be achieved at bitrates of about 12bpp (a 2:1 compression ratio). Normally you can aim at much lower bitrates (e.g., 1 bit per pixel, 24:1 compression ratio) and expect decent quality, but it'll depend on the images you're dealing with.
I have an optimally compressed png that I'm rotating by 1 degree using ImageMagick -
convert -rotate 1 crab.png crab-rotated.png
The size goes from 74 KB to 167 KB. How do I minimize that increase?
Orginal:
Rotated:
The increase in file size is probably due to less efficient compression. You won't be able to do anything about that unless you decrease the compression level (-quality option) or use a more efficient but lossy compression method (e.g. JPEG).
Here's the reason why I think this happens (I hope somebody can correct me if I am wrong). By rotating the image, you are introducing spatial frequencies that were not present in the original image. If these frequencies are not suppressed during compression, than the file size will inevitably increase. However, suppressing these frequencies may degrade the quality of your image. It's a delicate balance.
The amount of increase (or decrease) in filesize after rotation depends on the frequencies already present in the image, i.e. it is image-specific.
What's the maximum size an uncompressed 48x48 image can have? I'd like to set up a reference image for debugging.
48 * 48 = 2304
So, (2304 * number of channels * bytes per channel) bytes
W * H * BitsPerPixel
If BitsPerPixel is 32 (Millions of colors), then it would be 73,728 bits. divide that by 8 to get bytes (9,216). The actual size would vary between the uncompressed formats a bit, especially depending on their color capabilities.
For Bitmaps, this Wikipedia page mentiones some of the color options: http://en.wikipedia.org/wiki/Bitmap
Recently I wrote a primitive PNG writer. You have to put one byte infront of every line and add PNG as well as ZLIB headers and checksums. I'm not sure but I think you can have RGBA images with 16bit per channel. The raw data would be 48*49*2*4=9.4kB. So I would make sure that you can handle 16kB or so.
As you are talking about compression, I assume that you mean an image file.
The maximum size would depend on the file format and bit depth that you allow.
A 96 bpp TIFF image for example would be 46 kB.
A more reasonable format could be a 24 bbp BMP file, which is 7 kB.