How to Convert uint8 to Cell

조회 수: 3 (최근 30일)
Shannon Marie
Shannon Marie 2017년 10월 30일
편집: Guillaume 2017년 10월 31일
Hello,
How can I convert a uint8 variable into a cell? I am attempting to use the SHINE toolbox to mask some images, but the image is not in a cell format, which is required.
I am new to MATLAB, so any information regarding this would be helpful. Thanks!
  댓글 수: 2
Guillaume
Guillaume 2017년 10월 30일
The question does not make sense
  • Matlab does not have a data type called cell. However, it has a data type called cell array.
  • A cell array is a container for data of dissimilar types (e.g. characters and numbers), it would not make sense to store an image in a cell array. Images in matlab are not stored in cell array.
  • If an image were to be stored in a cell array how should that be done? A 3D cell array of pixels (height x width x colour plane)? A 2D cell array of RGB triplets? Something else
  • The class of the pixels (uint8) is completely independent of the method you use to store them. You could have a cell array of uint8 pixels, or a regular 3D matrix of uint8 pixels. Again using cell arrays does not make sense.
What is the exact wording of the requirements of your toolbox?
Shannon Marie
Shannon Marie 2017년 10월 30일
편집: Guillaume 2017년 10월 30일
The error is "The input must be a cell," but I do think the image needs to be a 2-dimensional array?
Here is the code:
if iscell(images) == 0
error('The input must be a cell.')
elseif min(size(images)>1)
error('The input cell must be of size 1 x numim or numim x 1.')
end

댓글을 달려면 로그인하십시오.

답변 (2개)

Guillaume
Guillaume 2017년 10월 31일
편집: Guillaume 2017년 10월 31일
I don't know where you got that toolbox but it's been poorly written (unnecessary else, incorrect test of size, and the name of the type is cell array, not cell). I would be wary of using poorly written code.
Anyway, it looks like the code expect a cell array containing several images (note the plural on the variable) name. Each cell of the cell array should be a 2d or 3d matrix representing your image.

Image Analyst
Image Analyst 2017년 10월 31일
I have no idea what the SHINE toolbox is but it apparently wants your image(s) to be in cell(s). So just enclose them in braces. Like if grayImage is your uint8 image, then put it into a cell array
ca{1} = {grayImage};
You can add additional cells with more images if you want. Then call your SHINE toobox function passing it the cell or cell array:
someOutput = SomeShineFunction(ca); % Send in the cell "ca", not grayImage.
I can't really say much more without seeing the function definition line, and perhaps some comments about what it expects for input variables.

카테고리

Help CenterFile Exchange에서 Convert Image Type에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by