can GPUJPEG support one channel grayscale 8-bit? how to use?
Closed this issue · 4 comments
we use :
if (!isColor)
{
param_image.width = width;
param_image.height = height;
param_image.comp_count = 1;
// (for now, it must be 3)
param_image.color_space = GPUJPEG_NONE;
// or GPUJPEG_BT709 or GPUJPEG_YCBCR_JPEG
// (default value is GPUJPEG_RGB)
param_image.pixel_format = GPUJPEG_U8;
// or eg. GPUJPEG_422_U8_P1020
// (default value is GPUJPEG_444_U8_P012)
}
else
{
param_image.width = width;
param_image.height = height;
param_image.comp_count = 3;
// (for now, it must be 3)
param_image.color_space = GPUJPEG_RGB;
// or GPUJPEG_BT709 or GPUJPEG_YCBCR_JPEG
// (default value is GPUJPEG_RGB)
param_image.pixel_format = GPUJPEG_444_U8_P012;
// or eg. GPUJPEG_422_U8_P1020
// (default value is GPUJPEG_444_U8_P012)
}
if it's grayscale 8bit ,it not work
Yes, GPUJPEG supports a grayscale images – you should set a pixel format to GPUJPEG_U8
and ideally also comp_count to 1, color_space should be GPUJPEG_YCBCR_JPEG
.
I've tried to find out your problem but I was not able to reproduce the issue. Regarding this, I've modified the encode_raw example to take grayscale and it works for me when invoked as follows:
dd if=/dev/zero of=tst.r bs=$((1920*1080)) count=1
./encode_raw 1920 1080 tst.r
So I think that may be a good starting point.
To your example – if you will still not be able to make it run, please post rather a minimal working/broken example (as already described in contributing guidelines) and we can look at it.
Looking into your code and assuming that you use the first if-branch – it seems that this should work, but I don't know the rest of the code. Also color_space
should be rather GPUJPEG_YCBCR_JPEG
, but GPUJPEG_NONE
should work as well (it is deduced to be a YCbCR luma, anyways).
thanks,,it can work!
we set parameter:
gpujpeg_parameters param;
param.quality = 75;
we found the quality parameter can't set 100, it will not be encoded
ok, glad if it works for you
we found the quality parameter can't set 100, it will not be encoded
Do you have any steps to reproduce this? Quality 100 should normally work. I've tried with the sample image created as descibed above and it worked with gpujpegtool
:
gpujpegtool -e -s 1920x1080 -q 100 tst.r tst.jpg
It works also with the encode_raw example, if you set the quality to 100:
patch examples/encode_raw.c <<EOF
@@ -40,6 +40,7 @@ static int encode(int width, int height, int ch_count, const char *input_filenam
// set default encode parametrs, after calling, parameters can be tuned (eg. quality)
struct gpujpeg_parameters param;
gpujpeg_set_default_parameters(¶m);
+ param.quality = 100;
// here we set image parameters
struct gpujpeg_image_parameters param_image;
EOF
closing for now then if you don't have more info or comments on that