Hi I'm doing a simulation of the rolling shutter effect on matlab, enter image description here

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 enter image description here 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 propellerenter image description here

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]', 
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.
%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 
%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 
 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 
pixels from the axis perpendicular to the blade at the ouward end of 
 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 
axis of the blade, and (2) within the two ends of the blade. 

 %figure; imagesc(min([reshape(img, sensorSize(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);
 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; 



%close(vidObj); %% close video object 
  • \$\begingroup\$ Outside in bright sunlight your shutter speed willbe much higher than indoors by room lighting. \$\endgroup\$ – Brian Drummond Feb 12 '18 at 20:33
  • \$\begingroup\$ @BrianDrummond At the moment I'm thinking about adding the shutter speed into the simulation... \$\endgroup\$ – Yicheng Yang Feb 12 '18 at 20:44
  • \$\begingroup\$ This is a very interesting experiment that you are performing. Utilizing image processing with the dynamics of a plane propeller and plotting its motion in real-time. However... I'm very confused what your graph is showing because there are no labels anywhere. Your code is also pretty messy because you have words that are scattered on different lines of your comments. However, that could just be our website messing up when you tried to place it inside a block of code. Good luck on your project though. This will pretty awesome if you get this to work. \$\endgroup\$ – KingDuken Feb 12 '18 at 23:56
  • \$\begingroup\$ First, make sure your camera has a rolling shutter. Next, get a fantastically bright light and use a bright "prop" so that you can get the fastest shutter speed practical from your camera. Finally, make sure your propeller's speed is proportional to that of the plane. \$\endgroup\$ – uint128_t Feb 13 '18 at 1:24
  • \$\begingroup\$ @unit128_t Yes I'm sure my camera has rolling shutter, it is CMOS based imaging sensor, today I placed a white board behind the motor to make a clean background, I can see the shadow of the propeller blade more clearly. I think the matlab simulation gave a result at the condition that the shutter speed is at a sensible high value, but for my project I have to use goPro, which is quite subtle because the shutter speed is fixed. \$\endgroup\$ – Yicheng Yang Feb 13 '18 at 16:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.