Cell from Unint8 Conversion error

Illustration
kks_noor - 2021-05-22T12:16:51+00:00
Question: Cell from Unint8 Conversion error

clc; clear all; close all; A_folder = dir('E:\Notes\SEM 7\PRML\Alphabet Database\A\*.png'); B_folder = dir('E:\Notes\SEM 7\PRML\Alphabet Database\B\*.png'); C_folder = dir('E:\Notes\SEM 7\PRML\Alphabet Database\C\*.png'); D_folder = dir('E:\Notes\SEM 7\PRML\Alphabet Database\D\*.png'); E_folder = dir('E:\Notes\SEM 7\PRML\Alphabet Database\E\*.png'); A_result=cellmat(1,length(A_folder),32,32); B_result=cellmat(1,length(B_folder),32,32); C_result=cellmat(1,length(C_folder),32,32); D_result=cellmat(1,length(D_folder),32,32); E_result=cellmat(1,length(E_folder),32,32); m=100; for i=1:m A_result(1,i)=imread(strcat('E:\Notes\SEM 7\PRML\Alphabet Database\A\',A_folder(i).name)); B_result(1,i)=imread(strcat('E:\Notes\SEM 7\PRML\Alphabet Database\B\',B_folder(i).name)); C_result(1,i)=imread(strcat('E:\Notes\SEM 7\PRML\Alphabet Database\C\',C_folder(i).name)); D_result(1,i)=imread(strcat('E:\Notes\SEM 7\PRML\Alphabet Database\D\',D_folder(i).name)); E_result(1,i)=imread(strcat('E:\Notes\SEM 7\PRML\Alphabet Database\E\',E_folder(i).name)); end My database contains 100 greyscale images. I need to convert them into matrices with each cell containing a matrice of uint8 form of each image.  

Expert Answer

Profile picture of John Williams John Williams answered . 2025-11-20

Access Data in Cell Array.
 
In the above code, index the Cell Array with with Curly Braces, {} & not Smooth Parentheses, () in the for loop ie., change the code in the for loop to:
 
 
for i=1:m
  A_result{1,i}=imread(strcat('E:\Notes\SEM 7\PRML\Alphabet Database\A\',A_folder(i).name));
  B_result{1,i}=imread(strcat('E:\Notes\SEM 7\PRML\Alphabet Database\B\',B_folder(i).name));
  C_result{1,i}=imread(strcat('E:\Notes\SEM 7\PRML\Alphabet Database\C\',C_folder(i).name));
  D_result{1,i}=imread(strcat('E:\Notes\SEM 7\PRML\Alphabet Database\D\',D_folder(i).name));
  E_result{1,i}=imread(strcat('E:\Notes\SEM 7\PRML\Alphabet Database\E\',E_folder(i).name));
end

 


Not satisfied with the answer ?? ASK NOW

Get a Free Consultation or a Sample Assignment Review!