Constructing Image DataSets

From Eigenvector Research Documentation Wiki
Jump to navigation Jump to search

Building image DSOs can be accomplished via a GUI in Solo+MIA or PLS_Toolbox and MIA_Toolbox, or from the MATLAB command line when using PLS_Toolbox and MIA_Toolbox. A list of available methods can be found here.

Getting Started

In general, images are stored "unfolded" in an image DataSet where all spacial dimensions are unfolded into mode 1 and variables are unfolded into mode 2. You can retrieve a "folded" image from an image DataSet using the .imagedata field.

Unfolding Images

From a GUI

When using Solo+MIA or when you have MIA_Toolbox installed with PLS_Toolbox, image importing options automatically become available from the File/Import menus. You'll notice extra selections in the Import menu for images: File/Import Data/X Block. In this example we’re loading the JPEG from above directly into Analysis GUI.

Import Data List Box

After you've selected the file you wish to import, you're prompted to specify what modes are spatial (m-by-n pixels) and which mode you'd like them unfolded to.

Image Load GUI

Since the spatial data resides in the first two modes (768x512 pixels) we enter "1,2" in the Image Modes text box. Generally you put unfolded data into mode 1 of the new image dataset, so we'll use the default value of "1" in the Target Mode text box. Clicking OK loads the data into Analysis.

If you build a PCA model on this data you'll notice two things: an extra button on the toolbar, and different behavior when viewing data or scores.

The extra button opens the imagegui tool, see the MIA_Toolbox documentation for more information how imagegui works (or, if using PLS_Toolbox, type help imagegui at the command line). Also note that imagegui needs a model with at least 2 PCs calculated to be enabled.

Viewing data and scores will display information in its "folded", image form. In this example the 2 pc model scores plot displays in the original image spatial dimensions.

Scores Plot on Image

Most methods in Analysis GUI are image “enabled” in that they will automatically work on image data (PARAFAC will still operate on images but won't display "folded" image data). Be aware of size involved in image data. Large volumes of data will require extended amounts of time and memory to analyze. When a dataset is too large it will generate out of memory errors.

Converting an Existing DataSet

If you have an existing DataSet that is already unfolded, you can transform it into an image DataSet by defining the image size. This can be done from the DataSet Editor Transform menu (Transform>Convert to/from Image).

Convert to Image menu.

You will be prompted for information about the image. The first dialog box asks if the image is multivariate or univariate ( get more information about image types here). If you have a multivariate image you will then be prompted for the image size. This should be the size, in pixels of the original image. Once you've input the image size the function will then add this information to the DataSet and change it's type to "image".

From the MATLAB Command Line

With PLS_Toolbox and MIA_Toolbox, the easiest way to import an image via the command line is simply to use imageload. Calling imageload with no imputs will allow you to import and transform an image in the MATLAB workspace or from a .mat file.


Calling imageload with "other" switch will allow you to import from a number of standard image file types (.tiff, .png, .hdf, .bmp, .jpeg, .gif):


The following example shows how to build up an image dataset "manually". It uses the EchoRidgeClouds.jpeg image from the MIA_Toolbox/dems folder. This JPEG image contains RGB (Truecolor) information of size N x M x 3 where N and M are the pixel (spatial) dimensions. The following commands will load the image using the MATLAB image read command imread then unfold the image into the first mode of an image dataset using the buildimage command.

>> myimage = imread('EchoRidgeClouds.jpeg'); 
>> myimage = buildimage(myimage ,[1 2], 1, 'myNewImage') 
myimage =  
       name: myNewImage 
       type: image 
       date: 03-Oct-2005 10:31:03 
    moddate: 03-Oct-2005 10:31:03 
       data: 393216x3 [double] 
  imagesize: 768x512 
  imagemode: 1 
      label: {2x1} [array (char)] 
               Mode 1  [: ]  
               Mode 2  [: ]  
axisscale: {2x1} [vector (real)] 

What if you have an existing DSO with image data in it? Use the exact same command:

>> myimage = buildimage(mydso ,[1 2], 1, 'myNewImage') 

The last input to buildimage, 'myNewImage', renames the dataset (the default name is the variable name). The default setting for buildimage is to handle 3 dimensional data (three modes), see the documentation for specific settings.

Concatenating Images

Concatenating images can be performed, via Image Manager, in either the image (X,Y pixel or spatial) domain or the variable (spectral) domain. In the spatial domain images can be concatenated in the X direction, Y direction, Z direction, or "tiled" in X/Y plane. Concatenation in the variable domain is almost always done in the "existing" variable mode (dimension). If concatenating in a new variable mode this will effectively create n-way data where data will be unfolded on the spatial modes but retain the variable modes.

NOTE: If images are concatenated in the Z direction this results in a 4 dimensional dataset that is pixels by pixels by pixels by variable. This is often confused with concatenating in the existing variable dimension where each image is "stacked" in the variable dimension.

NOTE: When concatenating in image (spatial) domain, a new class set will be created with each (sub) image assigned to a class. This will allow for class based preprocessing (e.g., class centering to remove offset).

Visual explanation of Image Domain Concatenation


Visual explanation of Variable Domain Concatenation