im2vec

by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - Images
Introduced first in SolidGeometry 4.4, Creation date: 2018-12-19, Last change: 2025-09-14

simply converts/reshapes an image into a 1 x n vector

Description

used for polynomical classificators

Example Illustration

 missing image of im2vec(Iset)

Syntax

Vec=im2vec(Iset)

Input Parameter

Iset: Image

Output Parameter

Vec: Vector

Examples


imread('corn.tif',3); I=ans; whos I
V=im2vec(I);
whos V




Copyright 2018-2025 Tim C. Lueth. All rights reserved. The code is the property of Tim C. Lueth and may not be redistributed or modified without explicit written permission. This software may be used free of charge for academic research and teaching purposes only. Commercial use, redistribution, modification, or reverse engineering is strictly prohibited. Access to source code is restricted and granted only under specific agreements. For licensing inquiries or commercial use, please contact: Tim C. Lueth

Algorithm (Workflow)

This algorithm is a MATLAB function named im2vec that converts an image into a 1 x n vector. It is part of the SG-Library and was introduced in SolidGeometry 4.4. The function is used for polynomial classifiers.

Input Parameters

Output Results

Algorithm Steps

  1. Determine the number of color channels in the image using size(Iset,3). This value is stored in the variable r.
  2. Calculate the number of elements in the first color channel of the image using numel(Iset(:,:,1)). This value is stored in the variable n.
  3. Reshape the image into a 1 x n vector using the reshape function. The reshaped vector is stored in the variable Vec.

Example Usage

An example is provided in the comments of the code:

imread('corn.tif',3); I=ans; whos I
V=im2vec(I);
whos V

In this example, an image is read using imread, and the resulting image is stored in I. The im2vec function is then called with I as the input, and the output vector V is obtained.

Algorithm explaination created using ChatGPT on 2025-08-18 22:03. (Please note: No guarantee for the correctness of this explanation)

Last html export of this page out of FM database by TL: 2025-09-21