필터 지우기
필터 지우기

vectorizing 150 images, reshaping them and concatenating in computer vision

조회 수: 1 (최근 30일)
Ye
Ye 2015년 2월 6일
답변: Dima Lisin 2015년 2월 9일
I have 150 images in png format (161x261 pixels), named image001.png to image 150.png .
If I want to convert all these 150 images into data 150 data matrices, reshape them such that each image gives me a 42021x1 matrix and concatenate all 150 matrices into a 42021x150 matrix, is there a code to achieve this loop process? I am not sure how to do this as my knowledge of basic is pretty basic. Thanks.

답변 (1개)

Dima Lisin
Dima Lisin 2015년 2월 9일
You can read an image using the imread function. You can convert an image into a 1D array using the : operator.
% Pre-allocate the giant matrix. Use uint8 to save memory
output = zeros(161*261, 150, 'uint8');
% The main loop
for i = 1:15
% Read an image
im = imread(sprintf('image%00d.png', i));
% Convert to grayscale, assuming the image is RGB
im = rgb2gray(im);
% Copy into the giant matrix
output(i, :) = im(:);
end

카테고리

Help CenterFile Exchange에서 Dimensionality Reduction and Feature Extraction에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by