composeMosaicFromImageRegular: Regularly transform an image into a mosaic

Description Usage Arguments Author(s) See Also Examples

View source: R/composeMosaicFromImageRegular.R

Description

A function to compose the mosaic of an image based on regular tiles. This function will compute the mosaic by regularly replacing the pixels of the original image with tiles from a tile library.

Usage

1
2
3
composeMosaicFromImageRegular(originalImageFileName, outputImageFileName, 
  imagesToUseInMosaic, useGradients = FALSE, removeTiles = TRUE, 
  fracLibSizeThreshold = 0.7, repFracSize = 0.25, verbose = TRUE)

Arguments

originalImageFileName

The original image you want to use to create the mosaic from (note that for the sake of your computer's memory, this image should be small, about 128 or 256 pixels wide, or so...).

outputImageFileName

The filename (with the path) where you want the image to be stored. This image can be quite large, depending on the number of pixels in the original image and on the tiles.

imagesToUseInMosaic

A path with the folder where the tiles are contained (note that the tiles should be square and for the sake of your computer's memory, small, e.g. 40x40, 120x120 pixels or so...). You can use the function createTiles to create a folder with smaller tiles from a folder with your original images.

useGradients

A flag to indicate if approximate gradients should be taken into account when selecting the tiles.

removeTiles

A flag to indicate if the user wants to temporarily remove tiles from the library after using them, so tile repetition would be discoraged by the software. If the tile library is small, the tiles will be added back to the library after its size reaches a certain threshold (defined by fracLibSizeThreshold).

fracLibSizeThreshold

The fraction of the size of the original tile library when the tiles must be (randomly) put back into the library.

repFracSize

The fraction of the size of the original tile library to replace when filling back the array (it should be smaller than, or equal to, 1-fracLibSizeThreshold).

verbose

A flag indicating if the user wants to have messages during the mosaic creation.

Author(s)

Alberto Krone-Martins

See Also

composeMosaicFromImageRandom

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
# Set the filename of the original image
#origImgFileN <- system.file("extdata", "verySmallMoon.jpg", package="RsimMosaic") 
origImgFileN <- system.file("extdata", "reallyVerySmallMoon.jpg", package="RsimMosaic") 

# Set the folder where the tiles library is located
pathToTileLib <- system.file("extdata/2Massier", package="RsimMosaic")

# Set the filename of the output image (the mosaic!)
outImgFileN <- file.path(tempdir(), "verySmallMoon-2MASS-Mosaic.jpg")

# Create the mosaic
composeMosaicFromImageRegular(origImgFileN, outImgFileN, pathToTileLib, removeTiles=TRUE)

Example output

 ------------------------------------------------ 
    R Simple Mosaic composer - regular version   
 ------------------------------------------------ 

    Creating the library... 
    -- Tiles in the Library :  100 
    -- Tile dimensions :  60  x  60 

    Reading the original image... 
    -- Original image dimensions :  38  x  40 
    -- Output image dimensions :  2160  x  2280 

    Computing the mosaic... 

    Done!

RsimMosaic documentation built on May 2, 2019, 7:29 a.m.