MATLAB: While setting the ‘Parent’ property of ‘Image’: Value must be a handle.

Image Processing Toolboxparent property

%THis is my code%
clc;clear;close all;
vidObj=VideoWriter('peaks.mp4');
open(vidObj);
h=axis;
for i=1:141;
filename=strcat(num2str(i),'.bmp');
a=imread(filename);
image(a,'Parent',h);
h.Visible='off';
pause(1/30);
currFrame = getframe(gca);
writeVideo(vidObj,currFrame);
end
close(vidObj);
%Getting this error%
Warning: No video frames were written to this file. The file may be invalid.
> In VideoWriter/close (line 267)
In VideoWriter/delete (line 202)
In ex4 (line 1)
Error using image
While setting the 'Parent' property of 'Image':
Value must be a handle.
Error in ex4 (line 8)
image(a,'Parent',h);

Best Answer

You need to create an axes object (see here).
Use axes, not axis. Axis sets axis limits and aspect ratios.
h=axes;