Learn R Programming

adimpro (version 0.6.1)

adimpro: I/O Functions

Description

Create image objects of class "adimpro" from arrays, RAW-format files and other image formats.

Usage

read.raw(filename, type="PPM",
         wb="CAMERA",cspace="Adobe",interp="Bilinear",
         rm.ppm=TRUE, compress=TRUE)
read.image(filename, compress=TRUE)
make.image(x,compress=TRUE, gammatype="None", whitep = "D65", cspace="Adobe", scale="Original",xmode="RGB")

Arguments

filename
file name
x
Array or matrix containing RGB or greyscale values in the range (0,1) or (0,65535).
type
option settings for dcraw. default "PPM". type="png" allows to read greyvalue png images as RAW-data (used as internal solution to store RAW information)
wb
white balance. default "CAMERA"
cspace
defines the output color space, default "sRGB" (sRGB D65), alternatives are "RAW" (Camera specific), "Adobe" (Adobe 1998 D65), "wGamut" (Wide Gamut D65), "kodak" (Kodak ProPhoto D65) and "XYZ", see manpages of dcraw.
interp
defines the interpolation method, default "Bilinear", Alternatives are "VNG", "AHD", "FourC" (Four color interpolation) and "Halfsize", see manpages of dcraw. "VNG" seems to provide the smallest spatial correlations.
rm.ppm
remove intermediate tmp file? default TRUE
gammatype
character, determines the type of gamma correction within the image. "ITU" stands for ITU-R BT.709-3 as e.g. used by dcraw. Alternatives recognized within the package are "None", "sRGB" and "CIE" (CIE L*). Please specify if you know
whitep
White point in xyY space. Can be given as one of (character) c("A","B","C","E","D50","D55","D65","D75","F2","F7","F11") or as a two element numeric vector of chromatic xy coordinates. "D65" correspo
compress
logical, determines if image data are stored in raw-format.
scale
"Original" scales to (0,max(img$img)) if min(img$img)<0< code="">, otherwise keeps the original scale. "Maxcontrast" scales each channel to maximum contrast
xmode
xmode determines how to interpret the values in x if length(dim(x))==3. Implemented are xmode="RGB" (default) and xmode="HSI"

Value

  • object of class "adimpro" containing the image. The object has the following components:
  • imgarray containing the color values in the color space specified by value$type.
  • typethe color space.
  • depthcolor depth, here "16bit".
  • dimvector of length 2 containing the number of pixel in horizontal and vertival direction.
  • filethe argument file identifying the image.
  • cspacethe type of rgb space used, as specified by cspace.
  • interpinterpolation applied by dcraw, as specified by interp.
  • gammahas a gamma correction been applied, here FALSE for read.raw) and TRUE for read.image
  • gammatypetype of gamma correction read.image.
  • wbtype of white balance, as specified by wb.
  • compressedimage data are stored as raw-vector (TRUE) or array of integers (FALSE).

Details

If ImageMagick is available on the system, read.image reads any of the following image file formats: c("tif", "tiff", "pgm", "ppm", "png", "pnm", "gif", "jpg", "jpeg") converts it into a temporary "pgm" or "ppm" file. This file is removed after reading the image. If ImageMagick is not available only "pgm", "ppm" and "pnm" formats can be processed.

If dcraw is available on the system, read.raw reads many RAW formats. type sets options to dcraw: "PPM" sets "-4", "RAW" sets "-4 -d", "HALFSIZE" sets "-h", "INFO" sets "-i -v". wb indicates, which white balance should be used: "NONE", "AUTO", "CAMERA".

Functions read.raw(file,type="RAW") and read.image(file) provide identical results on png-mages. If the result is a color, greyvalued or RAW image depends on the contend of the comment associated with the png-image.

make.image converts an appropriate 2 or 3 dimensional array to an image object of class "adimpro".

See Also

read.image

Examples

Run this code
img1 <- read.raw(system.file("img/rawimage.png",package="adimpro"),type="RAW")
img2 <- develop.raw(img1)
img3 <- read.raw(system.file("img/rawimage.png",package="adimpro"))
X11(width=7,height=3)
par(mfrow=c(1,3),mar=c(2,2,2,.5),mgp=c(2,1,0))
show.image(img1) 
title("RAW image")
show.image(img2) 
title("result of demosaicing")
show.image(img3) 
title("Default result of read.raw")

Run the code above in your browser using DataLab