i got error when i using imwrite function

8 次查看(过去 30 天)
When i run the following code error occured:
Error using imwrite (line 442)
Cannot write signed integer data to a JPEG file.
Error in cnn (line 19)
imwrite( data1, outfile, 'jpg');
data1 is the 512x512 int16.
clc;
clear all;
close all;
dirpath='C:\Users\suraj\Desktop\Tumor\New folder\brainTumorDataPublic_1-766\';
dirpath1='D:\Thesis Work\Thesis Report\jpgdataset\';
type='mat';
type1='jpg';
oldvar = '';
for j=4:9
infile = fullfile(dirpath, sprintf('%d.mat', j));
outfile = fullfile(dirpath1, sprintf('HK%d.jpg', j));
datastruct = load(infile);
fn = fieldnames(datastruct);
firstvar = fn{1};
data = datastruct.(firstvar);
data1 = data.image;
imwrite( data1, outfile);
if ~strcmp(oldvar, firstvar)
fprintf('loading from variable %s as of file %d\n', firstvar);
end
end

回答(0 个)

类别

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