Skip to content
This repository has been archived by the owner on Jul 6, 2022. It is now read-only.
/ img4d Public archive

PNG decoding / encoding / image processing with no dependencies

License

Notifications You must be signed in to change notification settings

DYGV/img4d

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

img4d

licence status

PNG Decoder/Encoder/image processing with no dependencies.
Please see current status on commit page or dub page

Please feel free to throw PRs or issues.

Examples

original grayscale gamma correction FT(power spectrum)
lena gray_lena gamma_0.5 lena_psd

decode, convert to grayscale and encode

import required modules

import img4d;

load(decode)

Img4d img = new Img4d();
Pixel colorPix = img.load("png_img/lena.png");

rgb to grayscale

Pixel grayPix = img.rgbToGrayscale(colorPix);

save(encode)

 bool encodedData = img.save(grayPix, "png_img/encoded_lena_1.png");

Package

img4d

img4d_lib.decode

img4d_lib.encode

img4d_lib.edge

img4d_lib.fourier

img4d_lib.template_matching

img4d_lib.quality_evaluation

img4d

  • ref auto load(string filename)
  • ubyte[] save(ref Pixel pix, string filename)
  • bool save(ref Pixel pix, string filename, ubyte[] ancillary_chunks)
  • bool isGrayscale(int colorType)
  • auto canny(T)(T[][] actualData, int tMin, int tMax)
  • ref auto rgbToGrayscale(T)(ref Pixel pix, bool fastMode=false)
  • pure auto differ(T)(ref T[][] origin, ref T[][] target)
  • pure auto mask(T)(ref T[][][] colorTarget, ref T[][] gray)
  • Complex!(double)[][] dft(ubyte[][] data, Header hdr)
  • Complex!(double)[][] lpf(Complex!(double)[][] dft_matrix, int radius = 50)
  • Complex!(double)[][] hpf(Complex!(double)[][] dft_matrix, int radius = 50)
  • Complex!(double)[][] bpf(Complex!(double)[][] dft_matrix, int radius_low = 20, int radius_high = 50)
  • ubyte[][] psd(Complex!(double)[][] dft_matrix)
  • int[ubyte] pixelHistgram(ubyte[][] data)
  • ubyte[][] gammaCorrection(ubyte[][] data, double gamma)
  • auto rectangle(ref ubyte[][] src, int[] pos, int[] size)
  • auto templateMatching(Header templateHeader, Header inputHeader, ubyte[][] templateImage, ubyte[][] inputImage, int type)
  • auto qualityEvaluation(ubyte[][] img_reference, ubyte[][] img_evaluation, QualityEvaluationType type)

img4d_lib.decode

  • Header readIHDR(ubyte[] header)
    Set Header struct and Return its struct

    • Params:
      ubyte[] header: Header byte-data
  • int byteToInt(T)(T[] data)
    Return ChunkData-length(Convert byte array to int)

  • string byteToString(T)(T[] data)
    Return Chunk Type(Convert byte array to string)

  • ubyte[] readIDAT(ubyte[] data)
    Calculate CRC and Return IDAT Chunk-Data

    • Params:
      ubyte[] data : IDAT array expect for Chunk-Data-Size
  • void crcCheck(ubyte[] crc, in ubyte[] chunk)
    The function of CRC calculation

    • Params
      ubyte[] crc : The CRC code at the end of the chunk
      ubyte[] chunk : Byte array to be CRC calculated
  • int paethPredictor(int left, int upper, int upperLeft)
    Calculate and Return Paeth-Predictor

  • int normalizePixelValue(int value)
    Return the value which are subtracted 256 if it exceeds 256

  • auto ubyte[][] inverseFiltering(ref ubyte[][] data, bool gray = false)

  • ubyte[][] parse(ref Header info, string filename)

img4d_lib.encode

  • void set32bitInt(ref ubyte[4] buf, uint data)

  • void set32bitInt(ref ubyte[2] buf, uint data)

  • uint read32bitInt(in ubyte[] buf)

  • auto makeChunk(ubyte[] chunk_type, ubyte[] chunk_data)

  • ubyte[] makeIHDR()
    Return IHDR which required for encoding

  • ubyte[] makeIDAT()
    Return IDAT which required for encoding

  • auto makeAncillary(int chunk_length, ubyte[] chunk_type, ubyte[] chunk_data)

  • ubyte[] makeIEND()
    Return IEND which required for encoding

  • auto makeCrc(ubyte[] data)
    Calculate and Return CRC value

  • int[] sumScanline(ref ubyte[][] src)
    Cast to int[] and Calculate sum every horizontal line

  • ubyte[][] chooseFilterType()
    Choose optimal filter and Return filtered pixel

img4d_lib.filter

  • pure ref auto inverseSub(ref ubyte[][] scanline)
  • pure ubyte[][] sub(ref ubyte[][] src)
    Calculate and Return Sub filter(Difference from left pixel)
  • pure ubyte[][] up(ref ubyte[][] src)
  • ubyte[][] ave(string op, string variable)(ubyte[][] src)
  • ubyte[][] paeth(string op, string variable)(ubyte[][] src)
  • pure ref auto joinVertical(T)(ref T[][] src)
    Make array vertical

img4d_lib.edge

  • auto differential(T)(T[][] array, T[][] filter)
  • auto gradient(T)(T[][] Gr, T[][] Gth)
  • auto hysteresis(T)(T[][] src, int t_min, int t_max)

img4d_lib.fourier

  • Complex!(double)[] _dft(Complex!(double)[] data, int num)
  • Complex!(double)[][] transpose(Complex!(double)[][] matrix, int h, int w)
  • ubyte[][] shift(ubyte[][] data, int h, int w)

img4d_lib.template_matching

  • this(Header templateHeader, Header inputHeader, ubyte[][] templateImage, ubyte[][] inputImage)
  • int[] SSD
    Sum of Squared Difference
  • int[] SAD
    Sum of Absolute Difference
  • int[] NCC
    Normalized Cross Correlation
  • int[] ZNCC
    Zero means Normalized Cross Correlation

img4d_lib.quality_evaluation

  • this(Header hdr, ubyte[][] img_reference, ubyte[][] img_evaluation)
  • double PixelSquare(ubyte[][] img)
    calculate squared sum of each pixel
  • double SE()
    Squared Error
  • double MSE()
    Mean Squared Error
  • double NormalizedMSE()
    Normalized Squared Error
  • double SNR()
    Signal-to-Noise Ratio
  • double PSNR()
    Peak signal-to-noise ratio
  • auto MSSIM()
    Mean Structural SIMilarity

About

PNG decoding / encoding / image processing with no dependencies

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

Packages

No packages published

Languages