Image Resolution Rescaling

Hello, I have to do some video scaling on 24-bit video for a 8-bit video dac and am looking for some help in scaling the data. The video image is 512 x 512 and each pixel is 24-bits. The video DAC is only 8- bits so I need to do some rescaling of the pixels. The images are arriving every 10msec but it is not crucial that I process each frame in 10msec, it could be 20msec but I cannot go beyond that because it will be noticable on the display. Does anyone know of some real-time algorithms that can help be scale my data without just throwing aways the LSB's. If anyone has done such a thing in an FPGA or know where I could get more information please let me know.

Thanks, joe

Reply to
jjlindula
Loading thread data ...

On Jul 13, 10:21 pm, " snipped-for-privacy@hotmail.com" wrote: Your pixel frequency seems to be about 25 MHz, i.e 40 nanoseconds per pixel. That should give you plenty of time for all sorts of algorithms, pipelined or not pipelined, if you really want to convert

24 bits into 8 bits. Or am I missing something? Peter Alfke

Reply to
Peter Alfke

So this is RGB data, at 8 bits/channel, to monochrome 8 bits ? Simplest conversion is a sum and divide by 3. If you have multipliers, this could be appx as * 21 and /64 (Shift 6)

You can do LSB rounding, to get within half a LSB, but you probably will not actually see that. Beyond that, what other scale did you have in mind ? - you could weight each of the RGB, and even do a Contrast/Brightness/Offset calc,

-jg

Reply to
Jim Granville

Hello all, thanks for responding to my post. The data rate may seem strange 10msec, but that's the rate. The video data is actually grayscale or I guess that would be monochrome data. I did find an algoritm off the net : pix + frameminValue y = ----------------------------------------------- * 2^b framemaxValue - frameminValue

where b is the number of bits of the video dac. In this equation I need to find the max and min values of the image frame. I might have to apply the max and min value on the next image frame which shouldn't be a problem. Does this equation sound do-able for a Stratix II FPGA?

thanks, joe

Reply to
jjlindula

This is doable in the FPGA only if you can read the frame twice. The internal storage won't buffer a 512x512x24 image. Once past that, this method is beyond simple but probably not accurate for your needs.

If your 24 bits are true grayscale, this shift of black and white levels may be desirable but it may be detrimental depending on your image.

What is the nature of your 24 bit data? To have so much grayscale information usually suggests there's specific purpose besides grayscale display. If you wish to display the nuances of the grayscale so your

8-bit output doesn't present "terracing" for a smooth transition between two close levels of gray, you can dither the error (the fraction that doesn't fit in 8 bits) in the adjacent pixels. Error diffusion is used extensively in imaging - at least from the print and copy side - and is probably documented for display applications as well.

If your grayscale isn't typically spread across most of the full

24'h000000 -> 24'hffffff range, the algorithm you found on the net will help expand the dynamic range of your image but will still throw away the lower bits. If your image is a polar bear eating vanilla ice cream in a snowstorm, this re-scaled image will produce VERY unusual results since many of those white, white, white pixels are now black or dark gray.

I'd suggest that for a 512x512 image where the total visual integration isn't very large, 8 bits are easily discarded and not all of the remaining 8 "fraction" bits are useful; for grayscale, I'd think 4 bits of fraction would be hard to discern from 3. But it's a pretty simple matter to retain the full 16-bit error for the one line of data that has to be retained for a proper error diffusion. Its overkill to use 16 bits when 3 is wholly sufficient, but you have 24 bits of data. I'm still not sure why. No application I've ever known has 24 bits of grayscale data.

A good error diffusion for large, smooth areas isn't the simplest thing to do but can easily be done (performance and resource-wise) in an inexpensive FPGA family. For print purposes I worked on a design recently that was running error diffusion (proprietary algorithm, sorry) at a mild 50 MHz. Because of all the tweaks for high-quality printing at high resolution (compared to your image, at least) the resources were much larger than most other functions we needed but at 512 pixel width AND use of grayscale rather than bi-level, your requirements would drop significantly.

If all you want is a "rough stab" at diffusing the error to avoid the terracing in a grayscale image, the implementation is probably extremely simple compared to our bi-level output requirements in printing where there's either a dot or there isn't.

If your 24-bit video isn't really 24 bits of grayscale, I hope you figure out what you want to accomplish. If it is RGB data that you want to convert to monochrome, look for colorspace conversion. The matrix operations are simple to convert from one color space to another (such as RGB to YCrCb or just Y for your grayscale needs) but is not a simple "sum and divide" suggested earlier. It's simple, but not that simple.

Good luck in defining your requirements and I hope your implementation is fun!

Reply to
John_H

I find a one dimensional diffusion works suprisingly well, if you're just dropping a few lsbs.

Reply to
Pete Fraser

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.