denoisingImageDatastore - Denoising image datastore - MATLAB (original) (raw)

Denoising image datastore

Description

Use a denoisingImageDatastore object to generate batches of noisy image patches and corresponding noise patches from images in anImageDatastore. The patches are used to train a denoising deep neural network.

This object requires Deep Learning Toolbox™.

Note

When you use a denoising image datastore as a source of training data, the datastore adds random noise to the image patches for each epoch, so that each epoch uses a slightly different data set. The actual number of training images at each epoch is increased by a factor of PatchesPerImage. The noisy image patches and corresponding noise patches are not stored in memory.

Creation

Syntax

Description

dnimds = denoisingImageDatastore([imds](#d126e72688)) creates a denoising image datastore using images from image datastoreimds. To generate noisy image patches, the denoising image datastore randomly crops pristine images from imds then adds zero-mean Gaussian white noise with a standard deviation of0.1 to the image patches.

dnimds = denoisingImageDatastore([imds](#d126e72688),[Name=Value](#namevaluepairarguments)) uses name-value arguments to specify the two-dimensional image patch size or to set the PatchesPerImage, GaussianNoiseLevel, ChannelFormat, and DispatchInBackground properties. You can specify multiple name-value arguments.

For example,denoisingImageDatastore(imds,PatchesPerImage=40) creates a denoising image datastore and randomly generates 40 noisy patches from each image in the image datastore, imds.

example

Input Arguments

Name-Value Arguments

expand all

Specify optional pairs of arguments asName1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Example: denoisingImageDatastore(imds,patchSize=48) creates a denoising image datastore that has a square patch size of 48 pixels.

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

Example: denoisingImageDatastore(imds,"patchSize",48) creates a denoising image datastore that has a square patch size of 48 pixels.

Patch size, specified as a positive integer or 2-element vector of positive integers. This argument sets the first two elements of thePatchSize property.

Data Types: single | double | int8 | int16 | int32 | uint8 | uint16 | uint32

Properties

expand all

Channel format, specified as "grayscale" or"rgb".

Data Types: char | string

Dispatch observations in the background during training, prediction, and classification, specified as a numeric or logical 0 (false) or 1 (true). To use background dispatching, you must have Parallel Computing Toolbox™. If DispatchInBackground istrue and you have Parallel Computing Toolbox, then denoisingImageDatastore asynchronously reads patches, adds noise, and queues patch pairs.

Gaussian noise standard deviation as a fraction of the image class maximum, specified as a scalar or 2-element vector with values in the range [0, 1].

Data Types: single | double

Number of observations that are returned in each batch, specified as a positive integer. You can change the value ofMiniBatchSize only after you create the datastore. For training, prediction, or classification, theMiniBatchSize property is set to the mini-batch size defined in trainingOptions (Deep Learning Toolbox).

This property is read-only.

Total number of observations in the denoising image datastore, specified as a positive integer. The number of observations is the length of one training epoch.

Number of random patches per image, specified as a positive integer.

Data Types: single | double | int8 | int16 | int32 | uint8 | uint16 | uint32

This property is read-only.

Patch size, specified as a 3-element vector of positive integers. If you create a denoising image datastore by specifying thepatchSize name-value argument, then the first two elements of the PatchSize property are set according to the value of the patchSize argument.

The ChannelFormat property determines the third element of the PatchSize property.

Data Types: single | double | int8 | int16 | int32 | uint8 | uint16 | uint32

Object Functions

combine Combine data from multiple datastores
hasdata Determine if data is available to read
partitionByIndex Partition denoisingImageDatastore according to indices
preview Preview subset of data in datastore
read Read data from denoisingImageDatastore
readall Read all data in datastore
readByIndex Read data specified by index fromdenoisingImageDatastore
reset Reset datastore to initial state
shuffle Shuffle data in datastore
transform Transform datastore
isPartitionable Determine whether datastore is partitionable
isShuffleable Determine whether datastore is shuffleable

Examples

collapse all

Get an image datastore. The datastore in this example contains color images.

setDir = fullfile(toolboxdir("images"),"imdata"); imds = imageDatastore(setDir,FileExtensions=".jpg");

Create a denoisingImageDatastore object that creates many patches from each image in the image datastore, and adds Gaussian noise to the patches. Set the optional PatchesPerImage, PatchSize, GaussianNoiseLevel, and ChannelFormat properties of the denoisingImageDatastore using name-value arguments. When you set the ChannelFormat property to "grayscale", the denoisingImageDatastore converts all color images to grayscale.

dnds = denoisingImageDatastore(imds, ... PatchesPerImage=20, ... PatchSize=64, ... GaussianNoiseLevel=[0.01 0.1], ... ChannelFormat="grayscale")

dnds = denoisingImageDatastore with properties:

     PatchesPerImage: 20
           PatchSize: [64 64 1]
  GaussianNoiseLevel: [0.0100 0.1000]
       ChannelFormat: 'grayscale'
       MiniBatchSize: 128
     NumObservations: 660
DispatchInBackground: 0

Tips

Version History

Introduced in R2018a