Hi Team,
Is their any way to identify if a .tiff and .jpg has colors in it pages.
Like we should be able to identify out of 10 pages of tiff we have 4 color pages.
Hi Team,
Is their any way to identify if a .tiff and .jpg has colors in it pages.
Like we should be able to identify out of 10 pages of tiff we have 4 color pages.
Hello, @Gpatil !
Could you please specify what you mean by “color pages”? Are you trying to differentiate between grayscale and full-color pages?
Scenario : I wanted to apply denoise, but denoising remove the color, Color is important to us.
So If I can detect a tiff page which has no color pixel in it, I will not apply denoising to it else I will . This will increase OCR accuracy for me
@Gpatil Understood. To check if an image has color pixels, you can use the following code snippet.
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(@"c:\temp\image.tiff"))
{
Aspose.Imaging.RasterImage rasterImage = (Aspose.Imaging.RasterImage)image;
// Load pixels for the whole image. Any rectangular part of the image can be specified as a parameter of the Aspose.Imaging.RasterImage.LoadArgb32Pixels method.
int[] pixels = rasterImage.LoadArgb32Pixels(rasterImage.Bounds);
bool hasColors = IsImageColored(pixels);
}
public static bool IsImageColored(int[] argbPixels)
{
foreach (var pixel in argbPixels)
{
int red = (pixel >> 16) & 0xff;
int green = (pixel >> 8) & 0xff;
int blue = pixel & 0xff;
if (!(red == green && green == blue))
{
return true; // The image has at least one colored pixel
}
}
return false; // All pixels are grayscale
}
Here you can find a code snippet for iterating over TIFF frames:
As for OCR, it’s a separate product with its own dedicated forum, so I can’t provide detailed information on that.
Here you can find documentation on LoadArgb32Pixels:
https://reference.aspose.com/imaging/net/aspose.imaging/rasterimage/loadargb32pixels/
And in case you are concerned with memory optimization issues, you can also use LoadPartialArgb32Pixels:
https://reference.aspose.com/imaging/net/aspose.imaging/rasterimage/loadpartialargb32pixels/