pontikos-lab / Relayer

Web app for segmenting OCT Scans
GNU Affero General Public License v3.0
2 stars 0 forks source link

Save image as JPEG #10

Closed IsmailM closed 6 years ago

IsmailM commented 6 years ago

TLDR;

Long version:

The images are currently saved as BMP - JPEGs would be better?

Also, some lossless compression would be good - The images are currently roughly 1.4MB. It currently takes an average of 1609ms to download an image (on a local server - so this will be longer on an actual web server). This time-lag in updating the image is very noticeable when moving the cursor across the interactive graph and as such, will be annoying. Just converting to JPEG will significantly decrease file size.

Also, there is an annoying white border around the image (see below). Can this be removed? Space on the website is already at a premium and the layout is being messed up by this - (I've manually added a black line to show the amount of whitespace around the image)...

001_jpg

IsmailM commented 6 years ago

I have updated saveResultsAndImages() function as follows (specifically the imshow() function call and the saveas() function call:

This removes the white border and saves as jpegs...

Moreover, the JPEGs are 180KB on average which is a lot smaller, than the average 1.5MB BMPs.

function saveResultsAndImages (octVolume, folder, ILM, RPE, ISOS, THICKNESS)

csvwrite( fullfile(folder,'ILM.csv'),       ILM);
csvwrite( fullfile(folder,'RPE.csv'),       RPE);
csvwrite( fullfile(folder,'ISOS.csv'),      ISOS);
csvwrite( fullfile(folder,'THICKNESS.csv'), THICKNESS);

% save image files of Scans with the segmentation
for i = 1: size(ILM,1)

    fh = figure('Visible','off'); imshow(flattenTrimOct(octVolume(:,:,i)),'border','tight');

    hold on;
    plot(1:size(ILM,2), ILM(i,:), 'r', 'linewidth',2);
    plot(1:size(RPE,2), RPE(i,:), 'g', 'linewidth',2);    
    hold off

    if      i > 99
        saveas(fh, fullfile(folder, num2str(i)), 'jpg');
    elseif  i > 9
        saveas(fh, fullfile(folder, ['0' num2str(i)]), 'jpg');
    else
        saveas(fh, fullfile(folder, ['00' num2str(i)]), 'jpg');
    end
end

end

@giovanniometto - can you have a look through the above and integrate into the matlab repository...