Re sampling Tiff Image

159 Views Asked by At

I need to re sample a Tiff image based on Navigation line(Seismic survey data).for Ex: the Tiff image with width=9857 and height=1187 and I need to resize(downsize) to Width=2160 and height=1187. I have tried with default C# encoders and compression algorithm and I know this is a reducing the size of 70% from the original image size. It lost the resolution of the image during downsize. is there any way to avoid it??

    private static Bitmap LZWCompression(Image source, int width, int height)
    {
        Bitmap Destbitmap = new Bitmap(source, width, height);

        Destbitmap.SetResolution(300, 300);

        ImageCodecInfo myImageCodecInfo;
        myImageCodecInfo = GetEncoderInfo("image/tiff");

        System.Drawing.Imaging.Encoder myEncoder;
        myEncoder = System.Drawing.Imaging.Encoder.Quality;
        EncoderParameters myEncoderParameters;
        myEncoderParameters = new EncoderParameters(1);
        EncoderParameter myEncoderParameter;
        myEncoderParameter = new EncoderParameter(myEncoder, 100000L);
        myEncoderParameters.Param[0] = myEncoderParameter;
        Destbitmap.Save(@"E:\Resized_LZW.tiff", myImageCodecInfo, myEncoderParameters);
        return Destbitmap;
    }


    private static ImageCodecInfo GetEncoderInfo(String mimeType)
    {
        int j;
        ImageCodecInfo[] encoders;
        encoders = ImageCodecInfo.GetImageEncoders();
        for (j = 0; j < encoders.Length; ++j)
        {
            if (encoders[j].MimeType == mimeType)
                return encoders[j];
        }
        return null;
    }
0

There are 0 best solutions below