Syntax
Vec=im2vec(Iset)
Input Parameter
Output Parameter
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
- Iset: This is the input image. It can be a multi-dimensional array representing an image with multiple color channels.
Output Results
- Vec: This is the output vector. It is a 1 x n vector that represents the reshaped image.
Algorithm Steps
- Determine the number of color channels in the image using
size(Iset,3)
. This value is stored in the variable r
.
- 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
.
- 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