Click here to Skip to main content
14,937,132 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Can any one please help me in compression of DICOM(.dcm) image file.
I am able to do it by using GZipStrim a class of using System.IO.Compression namespace which gives upto 50% compression and i want upto 80% compression. It may be possible by using lossy compression but i don't know how to do it?

please help me out how can i achieve it...?

What I have tried:

string[] sFiles = Directory.GetFiles(sInDir, "*.DCM*", SearchOption.AllDirectories);
int iDirLen = sInDir[sInDir.Length - 1] == Path.DirectorySeparatorChar ? sInDir.Length : sInDir.Length + 1;

using (FileStream outFile = new FileStream(sOutFile, FileMode.Create, FileAccess.Write, FileShare.ReadWrite))
using (GZipStream str = new GZipStream(outFile, CompressionLevel.Optimal,true))

foreach (string sFilePath in sFiles)
string sRelativePath = sFilePath.Substring(iDirLen);
if (progress != null)
CompressFile(sInDir, sRelativePath, str);

it is giving me 50% compression but wants to compress uoto 80%.
Updated 12-Aug-16 3:13am

1 solution

Gzip is general purpose compression tool, it don't have to understand what is compressed.
With lossy compression, the tool need to understand what is compressed.

So for lossy compression, you need:
- Open the file and load it in a picture/bitmap object.
- then apply the compression to the object.
you will have to choose between available compressions known of the object. Generally the compression is done when the object is saved in a given format usually JPEG.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900