i got error when i using imwrite function

9 Ansichten (letzte 30 Tage)
suraj singh
suraj singh am 5 Feb. 2019
Bearbeitet: KSSV am 5 Feb. 2019
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

Antworten (0)

Kategorien

Mehr zu Convert Image Type finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by