Open nehabagalkot opened 5 years ago
We can easily fix that with some simple post-processing, but could you please attach a sample TIFF file that does that here so I can have a look? Thanks!
New folder.zip Attached zip with input and output image.
Thanks! This is a 1-bit image and we're using pixConvert1To8()
for that in LeptonicaFrameConverter:
https://github.com/bytedeco/javacv/blob/master/src/main/java/org/bytedeco/javacv/LeptonicaFrameConverter.java#L91
If that doesn't work properly, I'm afraid this will need to be fixed in Leptonica.
Could you please report this issue upstream?
Its not only for 1-bit image, I tried it for color image, it inverts colors for it as well. ![Uploading color_output.jpg…]()
Could you also provide a small but complete code snippet to reproduce this issue?
import java.awt.image.BufferedImage;
import java.io.File;
import javax.imageio.ImageIO;
import org.bytedeco.javacpp.lept;
import org.bytedeco.javacpp.lept.PIX;
import org.bytedeco.javacv.Frame;
import org.bytedeco.javacv.Java2DFrameUtils;
import org.bytedeco.javacv.LeptonicaFrameConverter;
public class POCByteArray {
public static void main(String[] args) throws Exception {
PIX src = lept.pixRead("RotationTest.tiff");
LeptonicaFrameConverter c = new LeptonicaFrameConverter();
Frame f = c.convert(src);
BufferedImage img = Java2DFrameUtils.toBufferedImage(f);
ImageIO.write(img, "jpg", new File("RotationTestPIXbyte.jpg"));
}
}
Right, Leptonica loads all color images with 4 channels, but the order of the color channels doesn't necessarily map well with OpenCV or Java2D, see issue #1075.
I am using
LeptonicaFrameConverter c = new LeptonicaFrameConverter(); Frame f = c.convert(src); BufferedImage img = Java2DFrameUtils.toBufferedImage(f);
But the output image has inverted colors, ie 1->0 and vice versa. using it for .tiff format. How can I resole this? TIA.