Intel® Integrated Performance Primitives
Deliberate problems developing high-performance vision, signal, security, and storage applications.

Grayscale support in the IJL

jlorenzi
Beginner
340 Views
Hi,

I hope this isn't a really dumb question, but I can't get grayscale support to work. Whenever I try to load a grayscale jpeg it blows up. I know why, but I don't understand enough to fix it.

What I'm trying to do is load a grayscale image into an IJL_BGR (24-bit) buffer. However, I've been playing with this for half-a-day and I've tried every combination or pixel depths, color spaces, and buffer sizes that I can think of, and absolutely nothing seems to work.

I have DIBChannels = 3, DIBColor = IJL_BGR, JPGChannels = 1 and JPGColor = IJL_G.

When I'm loading the image, it blows up because what eventually happens is the library sets the need for upscaling to TRUE and color conversion to FALSE (jprops->upsampling_reqd = true, jprops->cconversion_reqd = false), but never sets a function to handle the upscaling/color conversion (i.e. ctx->__g_us_and_cc_mcu stays NULL, it's never set to something like US_General_MCU).

In decode_buffer.c, around like 543, you see where the ctx function gets filled in:

if((jprops->upsampling_reqd) && !(jprops->cconversion_reqd))
{
else if((jprops->jframe.ncomps == 3) && (jprops->DIBChannels == 1))
{
if(jprops->progressive_found == 0)
{
ctx->__g_us_and_cc_mcu = US_General_MCU;
}
else
{
ctx->__g_us_and_cc_mcu = US_General_P_MCU;
}
}


The only problem is, the jprops->jframe.ncomps = 1 (and jprops->DIBChannels = 3, but that's irrelevant). Inside of this 'if' block, there's only checks for jprops->jframe.ncomps == 3, but nothing for when it's 1. So, the function never gets set and it blows up because jprops_upsampling_reqd is true but there's no upsampling function.

I added a block to use the US_General_MCU callback, and it loads the image fine, but when I delete my pixel buffer it says there's heap corruption, so that doesn't seem to work.

So, I guess my real question is, how the heck do you load grayscale jpeg's into a 24-bit buffer (or even an 8-bit buffer)?

Thanks,

Jeff Lorenzini

0 Kudos
1 Reply
Vladimir_Dudnik
Employee
340 Views

Hi Jeff,

Assuming we are talk about IPP 5.3.

I do not understand what is the problem? As far as I know, our JPGView MFC application (which part of IJL package) open 1 channel JPEG images exactly in the way you mention (converting 1 channel JPEG into 3 channel BGR image), please take a look on FileOpenDlg.cpp, function GetImageFromJPG().

BTW, I recommend you to migrate from IJL to C++ JPEG codec which is part of JPEGView application. The reasons are: that codec supports 12-bit Extended Baseline mode, 2..16-bit Lossless mode, is threaded and demonstrate performance benefits when is running on multi-core system, is available for Windows, Linux and Mac OS X.

Regards,
Vladimir

0 Kudos
Reply