Question

I am trying to load an image and show it in MATLAB. It used to work on my other computer a while ago but on this computer the picture looks completely wrong and I am not sure why.

Thanks for all the help in advance.

This is the image I am loading: https://dl.dropboxusercontent.com/u/13524574/(1).png

This is how MatLAB shows it: https://dl.dropboxusercontent.com/u/13524574/WrongImage.png

Here is my code:

function main()

    workingDir = 'E:\MASTERS\MatLAB\FullVideo_R_OF_HOF\Images';
    S4A = zeros(360,640,3,256);

    %getting 256 frames of the images
    for ii = 1:256 
        S4A(:,:,:,ii)  = imread(fullfile(workingDir,'S4A',strcat('(',int2str(ii),').png')));
    end

    %showing first frame only
    imshow(S4A(:,:,:,1));

end
Was it helpful?

Solution

I'm not exactly sure what's going on in there with all those indices but I think I may be able to offer an alternative. Check out the third paragraph of the documentation, here, for return value information. I suggest using a cell array for clarity.

function main()

    workingDir = 'E:\MASTERS\MatLAB\FullVideo_R_OF_HOF\Images';
    S4A = zeros(360,640,3,256);

    %getting 256 frames of the images
    for ii = 1:256 
        A{ii}  = imread(fullfile(workingDir,'S4A',strcat('(',int2str(ii),').png')));
    end

    %showing first frame only
    imshow(A{1});

end
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top