Hi I'm doing a simulation of the rolling shutter effect on matlab,
in this case the image of the propeller is distorted, and I tried use a DC motor to simulate the plane's engine at home and filmed several sample video but I found the image I captured has shadow like this
Therefore I'm think how do I add the shadow into the simulation, I guess it's caused by shutter time, it's like sampling the average value of each pixel on the sensor during a short period of time(exposure), but I don't know how to deal with it so can anyone give me some advice ?
This is the simulation I got with a 2 blade propeller
I modified a piece of code that done by someone else to make continuous image, it seems working properly at the moment.
close all;
%% Propeller description
omega = 31; % Angular speed in rotations per second
length = 200; % Length of the blades in cm
width = 10; % Cross-section width in cm. (effective projection visible
from the camera. assumed constant.)
numBlades = 2; % number of blade pairs - assume even number of blades
discWidth = 0;
%% Camera description
frameSize = 600*[1 3/4]; % Width & height of the picture frame (in cm)
at the plane of the propeller (assuming the propeller is at the center
of the image)
sensorSize = 1024*[1 3/4]; % Sensor resolution in pixels
frameDuration = 1/30; % Time (in seconds) taken to scan all pixels in
the sensor
%% Initializations
initAngle = 0; % Initial orientation of the propeller. Can be assumed
to be anything without loss of generality.
numPixels = prod(sensorSize); % total number of pixels
tArrScan = [1:numPixels]'*frameDuration/numPixels; % Time instants at
which different pixels are sampled. Starting top-left.
% posPixels: position of the pixels. matrix of dimension numPixels x 2.
1 row for each pixel. 2 elements
% per pixel for X & Y coordinates.
posPixels = -0.5+[reshape(repmat([sensorSize(2):-1:1], sensorSize(1),
1), numPixels, 1)-sensorSize(2)/2 mod([0:numPixels-1]',
sensorSize(1))+1-sensorSize(1)/2];
posPixels = posPixels*frameSize(1)/sensorSize(1); % scaling to
translate the pixels on plane of the propeller.
distPixels = abs(posPixels * [1 i]'); % distance of the pixels from the
center of the frame.
angPixels = angle(posPixels * [i 1]'); % distance of the pixels from
the center of the frame.
figure(1);
%k = 0; %%to record specified number offrames
%filename='test'; % File name for video , you can change it
%combinedStr = strcat(filename,'.mp4'); %%combine name of video
to make it mp4
%vidObj = VideoWriter(combinedStr,'MPEG-4'); %%create video object and
tells type of video here type is .mp4
%vidObj.Quality = 100; %%defines quality of video, more the
value better is quality (slower the process)
%vidObj.FrameRate = 60; %%defines frame rate of video to be
stored
%open(vidObj); %%opens video object to record
while 1
% %%Camera operation
img = zeros(numPixels,1); % initialization
for kk=0:numBlades-1 % do for each balde
angleBlade = (2*pi/numBlades*kk)+initAngle+2*pi*mod(tArrScan*omega, 1);
% position of the blade when the pixels are being scanned.
distPixel2Blade = sum(posPixels .* [-cos(angleBlade) sin(angleBlade)],
2); % distance of the pixels (when they are scanned) from the axis of
the
blade
distPixel2PerpOrigin = sum(posPixels .* [sin(angleBlade)
cos(angleBlade)], 2); % distance of the pixels from the axis
perpendicular to the blade at origin
distPixel2PerpOutEnd = distPixel2PerpOrigin - length; % distance of
the
pixels from the axis perpendicular to the blade at the ouward end of
the
blade
pixelIsBesideTheBlade = (distPixel2PerpOrigin .* distPixel2PerpOutEnd)
<= 0; % Pixel is within the two ends of the blade
img = img+ min(abs(distPixel2Blade)<width, pixelIsBesideTheBlade); %
add 1 to the pixels that are: (1) within distance width/2 from the line
of
axis of the blade, and (2) within the two ends of the blade.
end
%figure; imagesc(min([reshape(img, sensorSize(1),
sensorSize(2))]',1));
colormap(gray); axis equal; % convert the pixels to 2-D image
%% Create a video to show the results progressively
initAngle=initAngle+2*pi*mod(tArrScan(786432)*omega, 1);
pause(1/100000);
imagesc(min([reshape(img, sensorSize(1), sensorSize(2))]',1));
colormap(gray); axis equal;
% imagesc(min([reshape(tmpimg+scnimg+bldimg, sensorSize(1), sensorSize(2))]',1)); colormap(gray); axis equal;
% imagesc(min([reshape(max(max(2*tmpimg,scnimg),bldimg), sensorSize(1), sensorSize(2))]',1)); colormap(gray); axis equal;
end
%close(figure(1))
%k=k+1
%close(vidObj); %% close video object