So if I detect a CMYK image I have a script written that attempts to convert the image to an RGB image so I can use imread on it (CMYK is not supported by imread for jpgs) and then tries to sharpen the image and convert it to black and white. Unfortunately the way I'm using applycform is not working and I keep getting an error that says "Cform structure is invalid for Named Color". Does anyone know anyway I might be able to resolve this or convert detect CMYK images to RGB images? All the Best!
inprof = iccread('USSheetfedCoated.icc');outprof = iccread('sRGB.icm');C = makecform('icc',inprof,outprof);for i=1:numFiles2 info=imfinfo(fullfile(workingDirectory,imageFiles2(i).name)); if info.ColorType == 'CMYK' fullfile(workingDirectory,imageFiles2(i).name) = applycform(fullfile(workingDirectory,imageFiles2(i).name),C); end frame = imread(fullfile(workingDirectory,imageFiles2(i).name)); frame = imsharpen(frame); gray = rgb2gray(frame); imwrite(gray,imageFiles2(i).name); end
Best Answer