Package png. February 20, 2015



Similar documents
Package PKI. July 28, 2015

MassArt Studio Foundation: Visual Language Digital Media Cookbook, Fall 2013

MMGD0203 Multimedia Design MMGD0203 MULTIMEDIA DESIGN. Chapter 3 Graphics and Animations

Chapter 3 Graphics and Image Data Representations

Package RCassandra. R topics documented: February 19, Version Title R/Cassandra interface

So you say you want something printed...

What Resolution Should Your Images Be?

Package empiricalfdr.deseq2

Package TSfame. February 15, 2013

Package retrosheet. April 13, 2015

Reduce File Size. Compatibility. Contents

Package PKI. February 20, 2013

ART 170: Web Design 1

RGB Workflow Key Communication Points. Journals today are published in two primary forms: the traditional printed journal and the

Package hive. January 10, 2011

A Basic Summary of Image Formats

Links. Blog. Great Images for Papers and Presentations 5/24/2011. Overview. Find help for entire process Quick link Theses and Dissertations

Color image processing: pseudocolor processing

COMP 250 Fall 2012 lecture 2 binary representations Sept. 11, 2012

Digimarc for Images. Best Practices Guide (Chroma + Classic Edition)

Optimizing Adobe PDF files for display on mobile devices

Data Storage 3.1. Foundations of Computer Science Cengage Learning

Digital Versus Analog Lesson 2 of 2

Comparison of different image compression formats. ECE 533 Project Report Paula Aguilera

designed and prepared for california safe routes to school by circle design circledesign.net Graphic Standards

Get the Best Digital Images Possible. What s it all about anyway?

Scanning in Windows XP: Basics Learning guide

Otis Photo Lab Inkjet Printing Demo

EPSON Perfection 2450 PHOTO. Scanner Parts. Scanner Specifications. Basic Specifications. US letter or A4 size ( inches [ mm])

Package bigdata. R topics documented: February 19, 2015

Smithsonian Institution Archives Guidance Update SIA. ELECTRONIC RECORDS Recommendations for Preservation Formats. November 2004 SIA_EREC_04_03

Chapter 7: Additional Topics

Adobe Certified Expert Program

Data Storage. Chapter 3. Objectives. 3-1 Data Types. Data Inside the Computer. After studying this chapter, students should be able to:

Package hive. July 3, 2015

Technical guidelines Product image specifications & the exchange of digital assets

Image Resolution. Color Spaces: RGB and CMYK. File Types and when to use. Image Resolution. Finding Happiness at 300 dots-per-inch

Calibration Best Practices

Simple Image File Formats

Introduction to Imagery and Raster Data in ArcGIS

Package httprequest. R topics documented: February 20, 2015

w w w. g e o s o f t. c o m

Designing for Print. How to build a file for successful printing East Second Street Duluth, MN

Best Practices: PDF Export

Komumaldata Barcoded PDF Forms PDF417 Barcode Generator Reference XFA (LiveCycle) Version Generator Version: 1.12

A. Scan to PDF Instructions

Package TimeWarp. R topics documented: April 1, 2015

Silverlight for Windows Embedded Graphics and Rendering Pipeline 1

Guidance on Using Scanning Software: Part 2. VueScan

A Adobe RGB Color Space

Package uptimerobot. October 22, 2015

UNIVERSITY OF CALICUT

Package MBA. February 19, Index 7. Canopy LIDAR data

Digital Image Fundamentals. Selim Aksoy Department of Computer Engineering Bilkent University

Barcode Definitions. Labels: Getting Started. Overview. Defining a barcode definition

ENTTEC Pixie Driver API Specification

Data warehousing with PostgreSQL

EPSON Perfection 1650/1650 PHOTO. Scanner Parts. Scanner Specifications. Basic Specifications. device Effective pixels

Version of Barcode Toolbox adds support for Adobe Illustrator CS

PixelWrench2 - Frequently Asked Questions

Package pxr. February 20, 2015

ANALYSIS OF THE COMPRESSION RATIO AND QUALITY IN MEDICAL IMAGES

MASKS & CHANNELS WORKING WITH MASKS AND CHANNELS

Distributed Image Processing using Hadoop MapReduce framework. Binoy A Fernandez ( ) Sameer Kumar ( )

Intel Modular Server System MFSYS25

TekBots TM Oregon State University. usb_cam User Guide. Version 1.0 By Adriaan Smit OSU EE Graduate Student

Introduction to MATLAB (Basics) Reference from: Azernikov Sergei

Understanding DPI and Pixel Dimensions

Image Processing and Computer Graphics. Rendering Pipeline. Matthias Teschner. Computer Science Department University of Freiburg

AD SPECIFICATIONS. Standard Banners. Site Served. Creative. Animation DAA Ad Marker * Raw Assets Delivery. Availability. Metrics

Guidelines concerning Fingerprint Transmission

Lesson 10: Video-Out Interface

Patch 1 for English Origin 6.1

Video-Conferencing System

Logo Standards Guideline

Firefox, Opera, Safari for Windows BMP file handling information leak. September Discovered by: Mateusz j00ru Jurczyk, Hispasec Labs

Package sendmailr. February 20, 2015

Package LexisPlotR. R topics documented: April 4, Type Package

Scanning and OCR Basics

Best practices for producing high quality PDF files

Creating Print-Ready Files

Today s topics. Digital Computers. More on binary. Binary Digits (Bits)

Print Services User Guide

Gates/filters in Flow Cytometry Data Visualization

Unit R082 Creating digital graphics. File Formats and the Properties of Digital Images and Graphics

Advanced visualization with VisNow platform Case study #2 3D scalar data visualization

Correcting the Lateral Response Artifact in Radiochromic Film Images from Flatbed Scanners

Instructions for Creating a Poster for Arts and Humanities Research Day Using PowerPoint

Package ggrepel. February 8, 2016

Package survpresmooth

Package DCG. R topics documented: June 8, Type Package

PowerPoint Interface Menu Bars Work Area Slide and Outline View TASK PANE Drawing Tools

Periodontology. Digital Art Guidelines JOURNAL OF. Monochrome Combination Halftones (grayscale or color images with text and/or line art)

How to resize, rotate, and crop images

Transcription:

Version 0.1-7 Title Read and write PNG images Package png February 20, 2015 Author Simon Urbanek <Simon.Urbanek@r-project.org> Maintainer Simon Urbanek <Simon.Urbanek@r-project.org> Depends R (>= 2.9.0) Description This package provides an easy and simple way to read, write and display bitmap images stored in the PNG format. It can read and write both files and in-memory raw vectors. License GPL-2 GPL-3 SystemRequirements libpng URL http://www.rforge.net/png/ NeedsCompilation yes Repository CRAN Date/Publication 2013-12-03 22:25:05 R topics documented: readpng.......................................... 1 writepng.......................................... 3 Index 6 readpng Read a bitmap image stored in the PNG format Description Reads an image from a PNG file/content into a raster array. Usage readpng(source, native = FALSE, info = FALSE) 1

2 readpng Arguments source native info Either name of the file to read from or a raw vector representing the PNG file content. determines the image representation - if FALSE (the default) then the result is an array, if TRUE then the result is a native raster representation. logical, if TRUE additional "info" attribute is attached to the result containing information from optional tags in the file (such as bit depth, resolution, gamma, text etc.). If the PNG file contains R metadata, it will also contain a "metadata" attribute with the unserialized R object. Value If native is FALSE then an array of the dimensions height x width x channels. If there is only one channel the result is a matrix. The values are reals between 0 and 1. If native is TRUE then an object of the class nativeraster is returned instead. The latter cannot be easily computed on but is the most efficient way to draw using rasterimage. Most common files decompress into RGB (3 channels), RGBA (4 channels), Grayscale (1 channel) or GA (2 channels). Note that G and GA images cannot be directly used in rasterimage unless native is set to TRUE because rasterimage requires RGB or RGBA format (nativeraster is always 8-bit RGBA). As of png 0.1-2 files with 16-bit channels are converted in full resolution to the array format, but the nativeraster format only supports 8-bit and therefore a truncation is performed (eight least significant bits are dropped) with a warning if native is TRUE. See Also rasterimage, writepng Examples # read a sample file (R logo) img <- readpng(system.file("img", "Rlogo.png", package="png")) # read it also in native format img.n <- readpng(system.file("img", "Rlogo.png", package="png"), TRUE) # if your R supports it, we ll plot it if (exists("rasterimage")) { # can plot only in R 2.11.0 and higher plot(1:2, type= n ) if (names(dev.cur()) == "windows") { # windows device doesn t support semi-transparency so we ll need # to flatten the image transparent <- img[,,4] == 0 img <- as.raster(img[,,1:3]) img[transparent] <- NA # interpolate must be FALSE on Windows, otherwise R will # try to interpolate transparency and fail

writepng 3 rasterimage(img, 1.2, 1.27, 1.8, 1.73, interpolate=false) } else { # any reasonable device will be fine using alpha rasterimage(img, 1.2, 1.27, 1.8, 1.73) rasterimage(img.n, 1.5, 1.5, 1.9, 1.8) } } writepng Write a bitmap image in PNG format Description Create a PNG image from an array or matrix. Usage writepng(image, target = raw(), dpi = NULL, asp = NULL, text = NULL, metadata = NULL) Arguments image target dpi asp text metadata image represented by a real matrix or array with values in the range of 0 to 1. Values outside this range will be clipped. The object must be either twodimensional (grayscale matrix) or three dimensional array (third dimension specifying the plane) and must have either one (grayscale), two (grayscale + alpha), three (RGB) or four (RGB + alpha) planes. (For alternative image specifications see deatils) Either name of the file to write, a binary connection or a raw vector (raw() - the default - is good enough) indicating that the output should be a raw vector. optional, if set, must be a numeric vector of length 1 or 2 specifying the resolution of the image in DPI (dots per inch) for x and y (in that order) - it is recycled to length 2. optional, if set, must be a numeric scalar specifying the aspect ratio (x / y). dpi and asp are mututally exclusive, speciyfing both is an error. optional, named character vector of entries that will be saved in the text chunk of the PNG. Names are used as keys. Note that the "R.metadata" key is reserved for internal use - see below optional, an R object that will be serialized into the "R.metadata" text key

4 writepng Details Value Note writepng takes an image as input and compresses it into PNG format. The image input is usually a matrix (for grayscale images - dimensions are width, height) or an array (for color and alpha images - dimensions are width, height, planes) of reals. The planes are interpreted in the sequence red, green, blue, alpha. Alternative representation of an image is of nativeraster class which is an integer matrix with each entry representing one pixel in binary encoded RGBA format (as used internally by R). It can be obtained from readpng using native = TRUE. Finally, writepng also supports raw array containing the RGBA image as bytes. The dimensions of the raw array have to be planes, width, height (because the storage is interleaved). Currently only 4 planes (RGBA) are supported and the processing is equivalent to that of a native raster. The result is either stored in a file (if target is a file name), in a raw vector (if target is a raw vector) or sent to a binary connection. If either dpi or asp is set, the sphy chunk is generated based on that information. Note that not all image viewers interpret this setting, and even fewer support non-square pixels. Either NULL if the target is a file or a raw vector containing the compressed PNG image if the target was a raw vector. Currently writepng only produces 8-bit, deflate-compressed, non-quantized, non-interlaced images. Note in particular that readpng can read 16-bit channels but storing them back using writepng will strip the 8 LSB (irrelevant for display purposes but possibly relevant for use of PNG in signalprocessing if the input is truly 16-bit wide). Author(s) See Also Simon Urbanek readpng Examples # read a sample file (R logo) img <- readpng(system.file("img","rlogo.png",package="png")) # write the image into a raw vector r <- writepng(img) # read it back again img2 <- readpng(r) # it better be the same identical(img, img2) # try to write a native raster img3 <- readpng(system.file("img","rlogo.png",package="png"), TRUE) r2 <- writepng(img3)

writepng 5 img4 <- readpng(r2, TRUE) identical(img3, img4) ## text and metadata r <- writepng(img, text=c(source=r.version.string), metadata=sessioninfo()) img5 <- readpng(r, info=true) attr(img5, "info") attr(img5, "metadata")

Index Topic IO readpng, 1 writepng, 3 rasterimage, 2 readpng, 1, 4 writepng, 2, 3 6