i got error when i using imwrite function
Show older comments
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
Answers (0)
Categories
Find more on Convert Image Type in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!