Transform rotated image to the original image

For solving part of my problem I needed to find the transformation matrix between the rotated image and its original so I told myself why not write the post in my blog about this problem. For this post I am going to show you how we can transform rotated image to the original image. Let’s start:

close all
clear all
%% Input images.

Detect features in both images and match the features:

Continue reading

Shape from shading Tsai and Shah approach

Tsai and Shah applied the discrete approximation of the gradient rst, then employed the linear approximation of the reflectance function in terms of the depth directly. Their algorithm recovered the depth at each point using a Jacobi iterative scheme. ( P. Tsai and M. Shah. Shape from shading using linear approximation. Image and Vision Computing, 12(8):487–498, 1994.)

Continue reading

Shape from shading Pentland approach

Pentland used the linear approximation of the reflectance function in terms of the surface gradient, and applied a Fourier transform to the linear function to get a closed form solution for the depth at each point. (Pentland takes the Fourier transform of both sides of the equation). (Pentland, A., “Shape Information From Shading: A Theory About Human Perception,” Computer Vision., Second International Conference on , vol., no., pp.404-413, 5-8 Dec 1988.)

Continue reading

Mobile camera as a webcam in MATLAB

lego car

Recently I bought this car and assembled it and I wanted to install wireless camera on top of that but I didn’t have wireless camera. I read in lifehacker that IP Webcam turns your Android phone into a wireless camera. So, the general solution would need two parts, one to broadcast the data from the device and another part to read this data into Matlab.

  • Install IP Webcam app from your mobile play store.
  • Open the app, tweak the settings (login/pass, resolution, image quality), set the desired resolution (will impact the speed!)
  • Scroll to the bottom and tap on ‘Start Server’
  • In the camera preview window, you can see the url at the bottom of the screen.
  • Open MATLAB and use below code to obtain a live preview window. Note that this uses JPG files for discrete frames, which is probably not the fastest way. The app can stream the video and/or audio in multiple ways.

mobile camera image

Continue reading

Background subtraction

Background subtraction, also known as Foreground detection, is a technique in the fields of image processing and computer vision wherein an image’s foreground is extracted for further processing (object recognition etc.). Generally an image’s regions of interest are objects (humans, cars, text etc.) in its foreground. Background subtraction is a widely used approach for detecting moving objects in videos from static cameras. The rationale in the approach is that of detecting the moving objects from the difference between the current frame and a reference frame, often called “background image”, or “background model.

The basic method of background subtraction is to compare |frame – background| with
a pre-defined threshold (theta). If the difference of a pixel is larger than theta, then classify it as foreground; otherwise, claim that it is background.

(video dataset)

Continue reading