Does downscaling actually decrease resolution? - page 2 - General Chat - CHDK Forum

Does downscaling actually decrease resolution?

  • 22 Replies
  • 12420 Views
*

Offline LjL

  • ****
  • 266
  • A720IS
Re: Does downscaling actually decrease resolution?
« Reply #10 on: 13 / July / 2008, 09:58:11 »
Advertisements
Well, the information is still there when you convert to RGB strictly speaking (again except for one of the green sensors!), because if you know that the image was obtained from a Bayer matrix, you can go back to the original - just move the pixels around to obtain the original Bayer pattern again (again, except for green, which you can't recover).

But in any case, note that you're assuming you have an additional bit of information: you know that the source is grayscale only.
That's information that you don't have, in principle (although, clearly, common sense and your eyesight tells you, in real life).

Now my qualitative reasoning goes that, if you really want to say you have more resolution in the raw file than in whatever-clever-same-size-RGB-format-you-come-up-with, you'd have to somehow also provide the degree of "grayscaleness" of the subject, and that's something that you don't know in general.

*

Offline fudgey

  • *****
  • 1705
  • a570is
Re: Does downscaling actually decrease resolution?
« Reply #11 on: 13 / July / 2008, 11:15:39 »
Now my qualitative reasoning goes that, if you really want to say you have more resolution in the raw file than in whatever-clever-same-size-RGB-format-you-come-up-with, you'd have to somehow also provide the degree of "grayscaleness" of the subject, and that's something that you don't know in general.

Hmm... my reasoning would be that if there is a scene (be it black & white or something else) for which a greater resolution can be achieved and that greater resolution is irreversably diminished by interpolation to RGB, this process cannot in general be considered reversible and there certainly is significant information loss taking place (in this b&w superresolution case, the lost information could be categorized as fine detail in areas of extreme contrast; not just in all-black&white images, but in any image with such areas the camera nor the photographer need to know of the existence of such areas for the information to exist).

Not that I care really, I just press the shutter and curse all that noise later.

*

Offline RaduP

  • *****
  • 926
Re: Does downscaling actually decrease resolution?
« Reply #12 on: 13 / July / 2008, 11:54:10 »
Without any mathematical point of view, what you originally asked could very well be true; the largest resolution we get from digital camera JPEGs is crappy by design when zoomed in on a PC, because it's been interpolated from neighboring pixels.

Actually, that's not true at all. Most DSLRs (except for those made by Sigma) use the very same interpolation method, and the images look very well when you view them at 100%. The P&S cameras look bad at 100% because they have crappy lenses, noisy sensors, and they do a lot of 'sharpening' to the point that 1 bad pixel can affect pixels as far as 5 rows away (I tested it).


On topic:
Even though most of the real life scenes are not just black, gray and white, each RGGB pixel in the camera will still get some sample of the luminance at the position where it is. That is because most of the colors (except for pure red, green and blue) will show some luminosity through any RGB filter. And by interpolating between the nearby RGGB pixels, you can, most of the time, correctly get the missing information.
But after you do the demosaicing, I am not sure you can go back to RGGB without losing some information in the process.

*

Offline LjL

  • ****
  • 266
  • A720IS
Re: Does downscaling actually decrease resolution?
« Reply #13 on: 24 / July / 2008, 06:58:07 »
Now I'm offtopic, but I thought I'd rather follow up here since it's slightly related than make a new thread.

I was thinking that when I shoot very detailed pictures (such as wide angle landscape shots with focus at infinity), the JPEG size I get is between 5 and 6 megabytes.

A raw file on my camera (8 megapixel) will be about 10 megabytes large. This is just double the above. Now, from an efficient lossless codec such as PNG, I'd expect about 50% compression on average, right? Or maybe PNG wouldn't be very efficient with the non-RGB raw data, but one certainly could devise something that is.

So, would it by any chance end up that raw files are actually smaller than the camera-processed JPEGs? That would be ironic, turning all the discussions about "do we really need raw" into "do we need JPEG at all" ;)

*

Offline fudgey

  • *****
  • 1705
  • a570is
Re: Does downscaling actually decrease resolution?
« Reply #14 on: 24 / July / 2008, 12:38:18 »
A raw file on my camera (8 megapixel) will be about 10 megabytes large. This is just double the above. Now, from an efficient lossless codec such as PNG, I'd expect about 50% compression on average, right? Or maybe PNG wouldn't be very efficient with the non-RGB raw data, but one certainly could devise something that is.

In my experience PNG isn't able squeeze all that much out of 16 bit RGB images (or maybe they were actually 14 bit, I can't remember). It probably performs better on our 10 bit images, but expect it to be much worse than its typical 8 bits performance.

Not that it matters much, since coding to much of anything advanced enough with our brave little ARM is probably going to end up painfully slow unless someone finds that the jpeg codec can be reprogrammed.  :D

*

Offline LjL

  • ****
  • 266
  • A720IS
Re: Does downscaling actually decrease resolution?
« Reply #15 on: 24 / July / 2008, 13:24:43 »
Bah yeah, although simple compression lossless-JPEG style shouldn't really be that slow I believe... considering you save SD card writing time, too... will be able to tell for sure in some time.

*

Offline RaduP

  • *****
  • 926
Re: Does downscaling actually decrease resolution?
« Reply #16 on: 27 / July / 2008, 10:29:43 »
PNG compression (lossless) sucks.
Better just implement some simple RLE or something (on each color channel), which should be pretty fast.

*

Offline LjL

  • ****
  • 266
  • A720IS
Re: Does downscaling actually decrease resolution?
« Reply #17 on: 27 / July / 2008, 15:32:05 »
PNG compression sucks? Have you drunk? :P It's certainly slow and complicated to implement, but it most certainly does not suck...

And I talked about lossless JPEG, that's a little predictive encoding, Huffman stored.

Run-length encoding on photographs... I doubt that work do anything like working.

*

Offline cyril42e

  • ***
  • 111
  • SD1000/Ixus70 1.02a
    • CR-TEKnologies
Re: Does downscaling actually decrease resolution?
« Reply #18 on: 27 / July / 2008, 22:53:09 »
PNG compression sucks? Have you drunk? :P It's certainly slow and complicated to implement, but it most certainly does not suck...

And I talked about lossless JPEG, that's a little predictive encoding, Huffman stored.
Yes PNG sucks for natural images, it uses a dictionnary algorithm, like zip&gif, it's efficient for schematics with few colors because it looks for pattern repetitions, but for natural images lossless JPEG (predictive+huffman[+rle]) is more efficient, and that's why it is used in lossless JPEG ;-). Moreover it's not very complicated to implement, nor adapting the prediction to the specific architecture of RAW files. I implemented it in Pascal when I was in highschool, maybe I'll try to adapt it in C to RAW files, could be fun...

*

Offline LjL

  • ****
  • 266
  • A720IS
Re: Does downscaling actually decrease resolution?
« Reply #19 on: 28 / July / 2008, 08:42:32 »
Well, the JPEG FAQ states that "the new PNG
standard outcompresses lossless JPEG on most images".

Wikipedia also mentions that "[PNG's DEFLATE compression method] is combined with prediction, where for each image line, a filter method is chosen that predicts the color of each pixel based on the colors of previous pixels and subtracts the predicted color of the pixel from the actual color", which would make the concept extremely similar to that of Lossless JPEG, and quite unlike ZIP or GIF even though the final encoding method might be similar.

Also, note that as per PNG specifications, different predictive filters can be applied in PNG on a scanline-by-scanline basis, while Lossless JPEG only allows one filter selection for the entire image, if I'm not mistaken.

P.S.: But don't get me wrong, lossless JPEG is an easier method to implement on CRWs for sure, and I always intended to implement that, not PNG compression (also because it's what DNG wants).

 

Related Topics


SimplePortal © 2008-2014, SimplePortal