Quantcast
Channel: OxyPlot (moved to GitHub)
Viewing all articles
Browse latest Browse all 2061

New Post: Show a multipage tiff file (by libtiff.net) with ImageAnnotation

$
0
0
I have found a solution: HeatMapSeries... but the render speed is bad and I have a problem in visualization (I need to 'transpose' the final plot). I hope there is another solution.
            // open a tiff
            Tiff tiff = Tiff.Open("merged8bit.tif", "r");

            // read tiff image
            FieldValue[] value = tiff.GetField(TiffTag.IMAGELENGTH);
            int imageLength = value[0].ToInt();

            // create a model
            PlotModel model = new PlotModel();

            LinearColorAxis colorAxis = new LinearColorAxis();
            colorAxis.Position = AxisPosition.Right;
            colorAxis.LowColor = OxyColors.White;
            colorAxis.HighColor = OxyColors.White;

            var palette = OxyPalette.Interpolate(255, OxyColors.Black, OxyColors.White);
            colorAxis.Palette = palette;

            model.Axes.Add(colorAxis);

            var heatMapSeries1 = new HeatMapSeries();
            heatMapSeries1.X0 = 0;
            heatMapSeries1.Y0 = tiff.ScanlineSize();
            heatMapSeries1.X1 = imageLength;
            heatMapSeries1.Y1 = 0;
            heatMapSeries1.Interpolate = false;
            heatMapSeries1.Data = new Double[imageLength, tiff.ScanlineSize()];

            byte[] buf = new byte[tiff.ScanlineSize()];

            for (int row = 0; row < imageLength; row++)
            {
                tiff.ReadScanline(buf, row);
                Parallel.For(0, tiff.ScanlineSize(), col =>
                {
                    heatMapSeries1.Data[row, col] = buf[col];
                });
            }

            model.Title = "TIFF";

            LinearAxis 
                axisX = new LinearAxis(),
                axisY = new LinearAxis();
            axisX.Position = AxisPosition.Bottom;

            model.Axes.Add(axisX);
            model.Axes.Add(axisY);

            model.Series.Add(heatMapSeries1);

            model.PlotType = PlotType.Cartesian;

            Plot.Model = model;

            tiff.Close();

Viewing all articles
Browse latest Browse all 2061


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>