C# Converting TIFF JPEG compression to TIFF CompressionCCITT4 gives a lot of noise -
for ocr engine need feed ocr engine tiff files ccitt4 compression. our scanner outputs tiff files jpeg compression. want convert these files c#, using system.drawing.imaging.
this results in images lot of noise. how can reduce noise?
my code:
list<byte[]> fret = new list<byte[]>(); imagecodecinfo fimagecodecinfo = getencoderinfo("image/tiff"); encoderparameters fencoderparameters = new encoderparameters(3); fencoderparameters.param[0] = new encoderparameter(system.drawing.imaging.encoder.compression, (long)encodervalue.compressionccitt4); fencoderparameters.param[1] = new encoderparameter(system.drawing.imaging.encoder.scanmethod, (int)encodervalue.scanmethodnoninterlaced); fencoderparameters.param[2] = new encoderparameter(system.drawing.imaging.encoder.rendermethod, (int)encodervalue.rendernonprogressive); // image forgtiff = image.fromstream(pinputtiff); guid objguid = forgtiff.framedimensionslist[0]; framedimension objdimension = new framedimension(objguid); int framecount = forgtiff.getframecount(objdimension); (int = 0; < framecount; i++) { memorystream ms = new memorystream(); forgtiff.selectactiveframe(objdimension, i); forgtiff.save(ms, fimagecodecinfo, fencoderparameters); ms.position = 0; fret.add(ms.getbuffer()); } return fret;
as brannon said, ccitt4 binary format (black/white) image automatically binarized. documentation says: "the ccitt3, ccitt4, , rle require pixelformat value set blackwhite. setting pixelformat other value resets compression property value default."
you can try reduce noise choosing better binarization threshold. can @ algorithms provided open-source imaging libraries aforge.net or emgucv.
Comments
Post a Comment