CalcPicPara.m



topics - functions - index - search


CalcPicPara.m


Calculates a few physical image parameters of JPG files
given in the character matrix FileMat, (e.g. FileMat=['Path1,filesep,File1';'Path2,filesep,File2'; ...]
In case SaveFilePath is empty or not a function input argument the program calls ReadFileNames.m
Open image files one by one adding these files to the file list (press cancel if done) or open a batch file
containing full file names (inclusive path) of existing files (each filepath in a column) in a txt file

The program needs a SaveFilePath in order to save the calculated parameter
If SaveFilePath is empty or not a function input argument the user will be asked
to choose an output file name (default is PicParaAll.txt)

The program saves all parameter in this file and a short version of the most
important ones in a SaveFilePath file with extension ".s"
The files contain a label header with labeld devided by blanks;
Use the "import with label" function to import these data into Stat programs like Jump, Statview etc.


The output matrix ParaMat is a n x m matrix with n=number of image files
and m=20+4x40 (just rgb) or m=20+7x40 (if rgb and hsv)
Some rows of ParaMat are are for future use => set to zero

If CalcAllSpatStatus is 0, empty or not a function input argument the program calculates
SVD and PFFT parameter for black and white only (if CalcAllSpatStatus=1 also red, green, blue, etc.)

if CalcHsvStatus is 0, empty or not a function input argument the program calculates
parameter for red, green and blue only (not hue, saturation and value)
if CalcHsvStatus is 0 the program calls rgb2hsv.m (RGB2HSV Convert red-green-blue colors to hue-saturation-value)


The rows used are the following:

Row 1: q = total number of pixel in horzontal direction inclusive black border
Row 2: p = total number of pixel in vertical direction inclusive black border
Row 3: Width = number of pixel in horzontal direction exclusive black border
Row 4: Height = number of pixel in vertical direction exclusive black border
Row 5: Height2Width = Width / Height
Row 6: Land2Port = -1 if landscape (Width>Height), 0 if quadaratic (Width=Height;) 1 if portrait (Width Row 7: Jpg100FileSize = original size of jpg file in bit without compression; JPG is a type of image compression which is - in some way - based on physiological rules
Row 8: Jpg900FileSize = size of jpg file in bit with 90% quality compression; Therefore JPG file size is a reasonable parameter of image complexity.
Row 9-20 for future use

Row 21-60: Parameter for image in black and white
Row 21-40: inclusive black border
Row 41-60: exclusive black border

Row 21 or 41: Brightness (Mean across all pixel)
Row 22 or 42: Contrast (Std across all pixel)
Row 23 or 43: Jpg100FileSize
Row 24 or 44: Jpg90FileSize
Row 25 or 45: RelSvd1 = Percentage of image explained by first singular value (first eigenimage); svd = Singular value decomposition; A parameter of image complexity
Row 26 or 46: RelSvd5 = Percentage of image explained by the first five singular values (first five eigenimages);
Row 27 or 47: Svd25 = Number of singular values explaining 25% of the image
Row 28 or 48: Svd50 = Number of singular values explaining 50% of the image
Row 29 or 49: HorHalfCut = Half cut frequency cutting the mean across all horizontal frequency distributions; PFFT across each of the p or Height horizontal pixel columns;
PFFT = Power Fast Fourier Transformation;
i.e. the mean power of the lower half of frequencies is as big as the mean power of the upper half, A ratio of higher to lower frequencies i.e. the higher the half cut frequency, the more higher image frequencies
Zero frequency is subtracted and power is multiplied by frequency
Row 30 or 50: VertHalfCut = Half cut frequency cutting the mean across all vertical frequency distributions; PFFT across each of the q or Width vertival pixel rows;
Row 31 or 51: MeanHalfCut = weighted mean of horizontal and vertical half cut frequencies (q x HorHalfCut + p x VertHalfCut) / (p+q) or (Width x HorHalfCut + Height x VertHalfCut) / (Height+Width)
Row 32 or 52: HorFita = a of best f ^-a fit fitting the mean frequency distribution across all horizontal frequency distributions;
A first and rough approximation of a frequency distribution of natural images is f ^-a, The bigger the a the more higher image freqencies,
Row 33 or 53: VertFita = a of best f ^-a fit fitting the mean frequency distribution across all vertical frequency distributions;
Row 34 or 54: MeanFita = weighted mean of horizontal and vertical a values (q x HorFita + p x VertFita) / (p+q) or (Width x HorFita + Height x VertFita) / (Height+Width)

Row 61-100: Parameter for red part of the image
Row 61-80: inclusive black border
Row 81-100: exclusive black border

Row 101-140: Parameter for green part of the image
Row 101-120: inclusive black border
Row 121-140: exclusive black border

Row 141-180: Parameter for green part of the image
Row 141-160: inclusive black border
Row 161-180: exclusive black border