Image Histogram equalization and save result(jpg format)

Discuss questions and projects related to processing of imaging data here
Post Reply
user-7094
Posts: 7
Joined: Thu Jan 01, 1970 1:00 am

Image Histogram equalization and save result(jpg format)

Post by user-7094 »

Hello,
I trying to make my image "Histogram equalization" and save result image with jpg format use ZeissImageLib.dll.
Here is my code:

Code: Select all

  Zeiss.Micro.Imaging.Primitives.Image2d image2D = new Zeiss.Micro.Imaging.Primitives.Image2d("Test.jpg");
  Zeiss.Micro.Processing.Primitives.HistogramEqualization2d histogramEqualization2D = 
    new Zeiss.Micro.Processing.Primitives.HistogramEqualization2d();
  histogramEqualization2D.ExecuteOnData(image2D);
  
  //save histogram equalization result image
  image2D.Save("HistogramEqualizationResult.jpg");
I meet exception like "System.DivideByZeroException" in "histogramEqualization2D.ExecuteOnData(image2D)".

If I change my code like as below

Code: Select all

  Zeiss.Micro.Imaging.Primitives.Image2d image2D = new Zeiss.Micro.Imaging.Primitives.Image2d();
  Zeiss.Micro.BinaryData binaryData = new Zeiss.Micro.BinaryData();
  image2D.Initialize(224, 224, Zeiss.Micro.Imaging.PixelType.Bgr24);
  image2D.Load(fileInfo.FullName, out binaryData);
  Zeiss.Micro.Processing.Primitives.HistogramEqualization2d histogramEqualization2D = 
    new Zeiss.Micro.Processing.Primitives.HistogramEqualization2d();
  histogramEqualization2D.ExecuteOnData(image2D);
   
  //save histogram equalization result image
  image2D.Save("HistogramEqualizationResult.jpg");
I get result file like "HistogramEqualizationResult.i2d", if I need to save result image with "jpg" format, I don't know how to do.

Could any one tell me how to improve my code or give some example?

Thanks for your attention,
Rick
user-4
Posts: 398
Joined: Thu Jan 01, 1970 1:00 am

Post by user-4 »

Hello Rick,

sorry, but it is not clear to me what you intend to do.

If you want to save an Image as '.jpg' Image2d is not the class to be used.

Please use ImageDocument instead and finally ImageDocument.SaveAs('myimage.jpg') should do what you expect.

I hope this helps as an introduction ...
user-7094
Posts: 7
Joined: Thu Jan 01, 1970 1:00 am

Post by user-7094 »

Hello,
If I need to get ImageDocument from Zeiss.Micro.Imaging.Primitives.Image2d. How can I do that?

Thanks for your attention,
Rick
user-4
Posts: 398
Joined: Thu Jan 01, 1970 1:00 am

Post by user-4 »

Hello ricklina90,

here comes a code snippet that roughly shows how to work with Image2d and ImageDocument.

Code: Select all

ImageDocument outputImage = new ImageDocument();

........

ImageSubBlockCollection outputSubBlocks = outputImage.SubBlocks;
outputSubBlocks.Clear();

........

ImageSubBlock outSubBlock = new ImageSubBlock();
outputSubBlocks.Add(outSubBlock);

........

PixelType pt = PixelType.Gray8; // Gray8 Bgr24
SubsetBounds bounds = new SubsetBounds(0, 0, width, height);
outSubBlock.Initialize(PixelType.Gray8, bounds);
outSubBlock.Fill(FillValue, FillValueGreen, FillValueBlue);
Image2d image = new Image2d(width, height, pt);

image.BeginAccess();

........ do something with image ........

image.EndAccess();

image.CopyPixelsToSubBlock(outSubBlock, Int32Rect.Empty);

........

outSubBlock.Bounds.StartX = 0;
outSubBlock.Bounds.SizeX = width;

outSubBlock.Bounds.StartY = 0;
outSubBlock.Bounds.SizeY = height;

.......

outputImage.RecalculateBounds();
I hope this helps!
user-7094
Posts: 7
Joined: Thu Jan 01, 1970 1:00 am

Post by user-7094 »

Hello

Thanks for the answer.Very appreciated. :)

Regards,
Rick
Post Reply