Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Converting JPEG to PNG Image With Alpha transparency

Hi guys, I'm trying to convert image from jpeg format to png format. I'm also trying to apply Alpha on image so png save imag must be with alpha channel. I am not able to execute this(result.push_back<mat>(mask);) line in the code successfully.

Mat jpegImageMat = Highgui.imread("mnt/sdcard/aaawatermark/bird.jpg"); Mat gray_image = new Mat(), mask = new Mat(), rgba_image = new Mat(); List<mat> result = new ArrayList<mat>(); Core.split(jpegImageMat, result); Imgproc.cvtColor(jpegImageMat, gray_image, Imgproc.COLOR_BGR2RGBA); Imgproc.threshold(gray_image, mask, 128, 255, Imgproc.THRESH_BINARY); result.push_back<mat>(mask); Core.merge(result, rgba_image); Highgui.imwrite("mnt/sdcard/aaawatermark1/rgba.png", rgba_image);

Anybody help me will be appreciated.

click to hide/show revision 2
retagged

updated 2014-05-22 05:16:55 -0600

berak gravatar image

Converting JPEG to PNG Image With Alpha transparency

Hi guys, I'm trying to convert image from jpeg format to png format. I'm also trying to apply Alpha on image so png save imag must be with alpha channel. I am not able to execute this(result.push_back<mat>(mask);) line in the code successfully.

Mat jpegImageMat = Highgui.imread("mnt/sdcard/aaawatermark/bird.jpg"); Mat gray_image = new Mat(), mask = new Mat(), rgba_image = new Mat(); List<mat> result = new ArrayList<mat>(); Core.split(jpegImageMat, result); Imgproc.cvtColor(jpegImageMat, gray_image, Imgproc.COLOR_BGR2RGBA); Imgproc.threshold(gray_image, mask, 128, 255, Imgproc.THRESH_BINARY); result.push_back<mat>(mask); Core.merge(result, rgba_image); Highgui.imwrite("mnt/sdcard/aaawatermark1/rgba.png", rgba_image);

Anybody help me will be appreciated.

click to hide/show revision 3
No.3 Revision

Converting JPEG to PNG Image With Alpha transparency

Hi guys, I'm trying to convert image from jpeg format to png format. I'm also trying to apply Alpha on image so png save imag must be with alpha channel. I am not able to execute this(result.push_back<mat>(mask);) line in the code successfully.

Mat jpegImageMat = Highgui.imread("mnt/sdcard/aaawatermark/bird.jpg");
Mat gray_image = new Mat(), mask = new Mat(), rgba_image = new Mat();
List<mat> List<Mat> result = new ArrayList<mat>();
ArrayList<Mat>();
Core.split(jpegImageMat, result);
Imgproc.cvtColor(jpegImageMat, gray_image, Imgproc.COLOR_BGR2RGBA);
Imgproc.threshold(gray_image, mask, 128, 255, Imgproc.THRESH_BINARY);
result.push_back<mat>(mask);
result.push_back<Mat>(mask);
Core.merge(result, rgba_image);
Highgui.imwrite("mnt/sdcard/aaawatermark1/rgba.png", rgba_image);

rgba_image);

Anybody help me will be appreciated.