module GDAL::RasterBandMixins::AlgorithmMethods::ClassMethods
Public Instance Methods
Compute the optimal PCT for RGB image. Implements a median cut algorithm to compute an “optimal” pseudo-color table for representing an input RGB image. This PCT could then be used with dither_rgb_to_pct
to convert a 24-bit RGB image into an 8-bit pseudo-colored image.
@param red_band [GDAL::RasterBand, FFI::Pointer] @param green_band [GDAL::RasterBand, FFI::Pointer] @param blue_band [GDAL::RasterBand, FFI::Pointer] @param colors [Integer] Number of colors to return; 2-256. @param color_interpretation [FFI::GDAL::GDAL::PaletteInterp] The type
of ColorTable to return.
@param progress_function [Proc, FFI:GDAL::GDAL.ProgressFunc] @param progress_arg [FFI::Pointer] Usually used when when using a
+FFI::CPL::Progress.GDALCreateScaledProgress+.
@return [GDAL::ColorTable]
# File lib/gdal/raster_band_mixins/algorithm_methods.rb, line 27 def compute_median_cut_pct(red_band, green_band, blue_band, colors, color_interpretation, progress_function: nil, progress_arg: nil) color_table = GDAL::ColorTable.new(color_interpretation) FFI::GDAL::Alg.GDALComputeMedianCutPCT( red_band, green_band, blue_band, nil, # This isn't yet supported in GDAL. colors, color_table.c_pointer, progress_function, progress_arg ) color_table end
24-bit to 8-bit conversion with dithering. Utilizes Floyd-Steinberg dithering, using the provided color table.
The red, green, and blue input bands do not necessarily need to come from the same file, but they must be the same width and height. They will be clipped to 8-bit during reading, so non-eight bit bands are generally inappropriate. Likewise, output_band
will be written with 8-bit values and must match the width and height of the source bands.
The ColorTable
cannot have more than 256 entries.
@param red_band [GDAL::RasterBand, FFI::Pointer] @param green_band [GDAL::RasterBand, FFI::Pointer] @param blue_band [GDAL::RasterBand, FFI::Pointer] @param output_band [GDAL::RasterBand, FFI::Pointer] @param color_table [GDAL::ColorTable, FFI::Pointer] @param progress_function [Proc, FFI:GDAL::GDAL.ProgressFunc] @param progress_arg [FFI::Pointer] Usually used when when using a
+FFI::CPL::Progress.GDALCreateScaledProgress+.
@return [GDAL::RasterBand] output_band
with the dithering algorithm
applied.
# File lib/gdal/raster_band_mixins/algorithm_methods.rb, line 66 def dither_rgb_to_pct(red_band, green_band, blue_band, output_band, color_table, progress_function: nil, progress_arg: nil) red_ptr = GDAL._pointer(GDAL::RasterBand, red_band) green_ptr = GDAL._pointer(GDAL::RasterBand, green_band) blue_ptr = GDAL._pointer(GDAL::RasterBand, blue_band) output_ptr = GDAL._pointer(GDAL::RasterBand, output_band) color_table_ptr = GDAL._pointer(GDAL::ColorTable, color_table) FFI::GDAL::Alg.GDALDitherRGB2PCT( red_ptr, green_ptr, blue_ptr, output_ptr, color_table_ptr, progress_function, progress_arg ) output_band end