classdef JPEG2000ImageCoderItem < CoderItem

    methods
        function obj=JPEG2000ImageCoderItem(inputparams)
            obj=obj@CoderItem(inputparams);
        end
        
        function cicoll=procItem(obj,item)
            cicoll=CodedImageItemCollection;
            for currRatio=obj.params.compressionratio
                A=imread(item.getfilename);
                 [fpathstr,fname,fext] = fileparts(item.getfilename);
                 outfname=sprintf('%s_jpeg2000_%d.jp2',fname,round(currRatio));
                 fprintf('Coding %s ...\n',outfname);
                 imwrite(A,outfname, 'CompressionRatio',currRatio);
                 params.compressionratio=currRatio;
                 params.name='JPEG2000';
                 ci=CodedImageItem(outfname,params,item);
                 cicoll=cicoll+ci;
            end
        end
        
    end

end