image based object detection and segemntation - matlab

I am currently studying image processing and learning matlab for my project.
I needed to know that if there is any method to detect a car from traffic image or parking lot image and then segment it out from it.
I have googled a lot but mostly the content is video based and I dont know anything about image processing.
language prefered : MATLAB
I am supposed to do this on images only not videos.

It's a very difficult problem in general. I'd suggest the easier way is to constrain the problem as much as possible - control lighting, size orientation of cars to detect, no occlusions.
This constraining has been the philosophy image processing has followed up until recently. Now the trend is that instead of constraining your problem, obtain as a massive amount of example data to train a suppervised learning algorithm. In fact it's possible that you can use a pre-trained model that would let you detect cars as it has been suggested in a previous answer.
There has been recently massive progress in the area of object detection in images and here are a few of the state of the art approaches based on neural network based approaches:
OverFeat
Rich feature hierarchies for accurate object detection and semantic segmentation (R-CNN paper)
Spatial Pyramid Pooling in Deep Convolutional Networks for Visual Recognition (paper)
Framework that you could use include:
Caffe: http://caffe.berkeleyvision.org/
Theano
Torch

You can use the detection by parts method:
http://www.cs.berkeley.edu/~rbg/latent/
It contains a trained model for "car" which you can use to detect cars, surround then with a bounding box and then extract them from the images.

Related

How to detect contours of object and describe it to compare on server with ARKit

I want to detect shape and then describe it (somehow) to compare it with server data.
So the first question is, is it possible to detect shape like blob with ARKit?
To be more specific, let's describe my usecase generally.
I want to scan image by phone, get the specific shape, send it on server, compare two images on server (server image is the real one, scanned image would be very similar) and then send back some data. I am not asking about server side, the only question about server side is what should I compare - images using OpenCV, some mathematical description of both images and try to find similarity, etc.).
If the question is hard to understand, let's split it on two easy questions:
1) How to scan 2D object by iPhone and save it (trim the specific shape from its background when object is black and background white).
2) Describe scanned object for comparision with almost the same object.
ARKit has no use here.
You will probably need a lot of CoreImage (for fixing perspective distortion and binarization) and OpenCV logic.
Perhaps Vision can help you a little bit with getting ROI from the entire frame, especially if the waveform image is located in some kind of rectangle.
Perhaps you can train a custom ML model that will recognize specific waveforms or waveforms in general to use with Vision.
In any case, it is not a trivial task.

Algorithm for ortho-rectification; mosaic-ing aerial images [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 8 years ago.
Improve this question
I'm working on ways of collecting farm aerial images (images collected from a helicopter in a perpendicular fashion) that I'd want to stitch them together to build the whole photo of the area that's being covered and then I wanted to run analytics.
I'm assuming the images will come with [latitudue, longitude] coordinates, to help me determine the spots to place the images.
To understand the issues with this technology, I tried manually stitching pictures taken from my phone of some sample area in my back yard. I experienced that the edges don't usually look the same because they are being seen by the camera from different sides or angles. I guess this is a distortion in image that could potentially be fixed by ortho-rectification (not completely sure).
I quickly created the following picture to help explain my problem.
My question to you:
What are the algorithms/techniques used to do ortho-rectification?
What tools would best suit my needs: opencv, or processing or matlab or any other tool that could easily help in rectification of images and creating a mosaic photo?
What other issues should be considered in doing aerial imagery mosaic-ing and analytics?
Thank you!
Image stitching usually assumes that the camera center is fixed across all photos, and uses homographies to transform the images so that they seem continuous. When the fixed camera center assumption is not strictly valid, artifacts/distortions may appear due to the 3D of the scene. If the camera center moved by a small distance compared to the relief of the scene, "seamless image blending" techniques may be sufficient to blur out the distortions.
In more extreme cases, ortho-rectification is required. Ortho-rectification (Wikipedia entry) is the task of transforming an image observed from a given perspective camera into an orthographic (Wikipedia entry) and usually vertical point of view. The orthographic property is interesting because it makes the stitching of several images much easier. The following picture from Wikipedia is particularly clear (left is an orthographic or directional projection, right is a perspective or central projection):
The task of ortho-rectification usually requires having a 3D model of the scene, in order to map appropriately intensities observed by the perspective camera to their location with respect to the orthographic camera. In the context of aerial/satellite images, Digital Elevation Models (DEM) are often used for that purpose, but generally have the serious drawback of not including man-made structures (only Earth relief). The NASA provides freely the DEM acquired by the SRTM missions (DEM link).
Another approach, if you have two images acquired at different positions, you could try to do a 3D reconstruction using one of the stereo matching technique, and then to generate the ortho-rectified image by mapping the two images as seen by a third orthographic and vertical camera.
OpenCV has several interesting function for that purpose (e.g. stereo reconstruction, image mapping functions, etc) and might be more appropriate for intensive usage. Matlab probably has interesting functions as well, and might be more appropriate for quick tests.
First, rectification is some kind of warping, but not the one that you need. Regular rectification is used in stereo to ensure that matching points lie on the same row - not your case. Ortho-rectification warps perspective projection into orthographic - again not your case. Not only you lack a 3D model for this warping to calculate but also you dont need it since your perspective distortions are negligible and you already have image pretty close to ortho ( that is when the size of the objects is small compared to the viewing distance perspective effects are small).
You problems in aligning two images stem from small camera rotations between shots. To start fixing the problem you need to ensure that your images actually overlap by say 30%. To read about this see chapter 9 of this book.
What you need is to review a regular image stitching techniques that use homography to map two images. Note that doing so assumes that images are essentially flat. To find homography you can first manually select 4 points in one image and 4 matching points in another image and run openCV function findHomography(). Note that overlap is required to find the matches (in your picture there is no overlap). warpPerspective() can warp images for you after homogrphy is found.
"What are the algorithms/techniques used to do ortho-rectification?
If you want a good overview of the techniques, then the book "Multiple View Geometry in Computer Vision" by Hartley & Zisserman might be a good place to start: http://www.robots.ox.ac.uk:5000/~vgg/hzbook/
Andrew Zisserman also has some tutorials available here at www.robots.ox.ac.uk/~az/tutorials/ which might be more accessible/make it easier for you to find the particular technique you want to use.
"What tools would best suit my needs: opencv, or processing or matlab or any other tool that could easily help in rectification of images and creating a mosaic photo?"
OpenCV has a fair few number of tools available - take a look at Images stitching for starters. There's also a lot available for correcting distortion. However, it doesn't have to be the tool you use, there are others!

Taking Depth Image From Iphone (or consumer camera)

I have read that it's possible to create a depth image from a stereo camera setup (where two cameras of identical focal length/aperture/other camera settings take photographs of an object from an angle).
Would it be possible to take two snapshots almost immediately after each other(on the iPhone for example) and use the differences between the two pictures to develop a depth image?
Small amounts of hand-movement and shaking will obviously rock the camera creating some angular displacement, and perhaps that displacement can be calculated by looking at the general angle of displacement of features detected in both photographs.
Another way to look at this problem is as structure-from-motion, a nice review of which can be found here.
Generally speaking, resolving spatial correspondence can also be factored as a temporal correspondence problem. If the scene doesn't change, then taking two images simultaneously from different viewpoints - as in stereo - is effectively the same as taking two images using the same camera but moved over time between the viewpoints.
I recently came upon a nice toy example of this in practice - implemented using OpenCV. The article includes some links to other, more robust, implementations.
For a deeper understanding I would recommend you get hold of an actual copy of Hartley and Zisserman's "Multiple View Geometry in Computer Vision" book.
You could probably come up with a very crude depth map from a "cha-cha" stereo image (as it's known in 3D photography circles) but it would be very crude at best.
Matching up the images is EXTREMELY CPU-intensive.
An iPhone is not a great device for doing the number-crunching. It's CPU isn't that fast, and memory bandwidth isn't great either.
Once Apple lets us use OpenCL on iOS you could write OpenCL code, which would help some.

Shape detection using MATLAB

I am working on car parking system project. For that, I would like to detect the presence of a car.
Can anybody tell me how I can accomplish this using MATLAB?
Also, what is the algorithm for detecting a car?
There's a whole world of methods for object detection in images. You need to learn a little bit about image processing to solve this problem. I suggest you read about template matching or more generally about Object recognition. Specifically for car detection, if you know they will be seen at a certain angle (head on, for example) i'd try Viola-Jones detection which is implemented in OpenCV as haar-based feature cascade detection. Although OpenCV is not a matlab library, you can probably find something in matlab's image processing toolboxes that does a similar job (or interface into OpenCV)
Background subtraction would be a simple place to start.
In a nutshell:
Can capture an image of your empty parking lot. This is your reference image.
Compare the current image of your parking lot with the reference image. The parts that are different will be of interest.
Problems:
You need to keep updating your reference image to stay current with the conditions (e.g. day, night, cloudy, raining). Sometimes this may not be possible, because your reference image needs to have no cars in it for the approach to work.
Moving things in the background (like trees shaking in the wind) will come up as false positives
Have you considered using 3D/stereoscopic imaging in addition to using 'normal' images? If yes you could open up a whole new world of methods and intelligent tricks to remove objects based upon their distance to the camera. Then, any object that is a certain, fixed distance from the camera (e.g. your background) is easily removable and you can just process the new parts of the image (e.g. cars).
If this interests you I can supply you with an algorithm I have developed to detect animals in a livestock pen, which is a similar concept.

Infrared image processing in Matlab

i would like to process infrared imaging in Matlab. Any kind of processing or techniques.
Is there any built-in function in Matlab?
And can anyone suggest any books or articles,as well as resources for sample Far Infrared images.
Thanks!
You may want to have a look at the image processing toolbox. There, you find plenty of built-in functionality for denoising and segmentation of any kind of images.
For more detailed answers, I suggest that you let us know in more detail what kind of processing that you want to do.
EDIT
Infrared images are normally grayscale images. Thus, it is very straightforward to false-color them by mapping the gray levels to colors (i.e. by applying a different colormap).
%# load a grayscale image
img = imread('coins.png');
%# display the image
figure
imshow(img,[]);
%# false-color
colormap('hot')
For more information about general techniques, you may want to Google 'infrared image processing' and start looking at the hits related to your specific application.
In general, processing of infrared images is not different from processing other grayscale images. What specific algorithms you apply depends very much on the image and the purpose of the processing.
LWIR imagery can be used for a large number of different applications. In general, each application domain has its own history, terminology and mathematical conventions.
As an example, we can use LWIR imagery for:
Detecting faulty components or components that are likely to fail.
Medical imaging for diagnosis of skin disorders.
Finding humans in Search & Rescue or border-control applications.
Detecting & classifying aircraft, missiles, vehicles etc... for various defense applications.
Geographical or Oceanographic research (using LWIR satellite imagery).
Each of these applications will rely upon very different techniques. The image processing toolbox may well be useful for some of these application areas, but, in general, you need to look at resources (software, textbooks, journals etc...) that are specific to the application domain or the specific sensor system that you will be using.
I don't think that the processing infrared images in general will not be different from processing visible-color images. As far as i came to know, during the processing of infrared images, we have to use raw data image which contains temperature information rather than pseudo color image which contains only the color intensity from 0-255.