Difference between revisions of "Assignment 4 part 1: Make a fake image"
(Created page with "{{Template:20.309}} ==Overview== All software has to be tested. In order to test the code you are developing, you will need images of fluorescent microspheres. One idea is t...") |
(→Overview) |
||
Line 3: | Line 3: | ||
==Overview== | ==Overview== | ||
− | All software has to be tested. | + | All software has to be tested. The code you will develop for this part of the lab measures the size and position of fluorescent microspheres in images. To test the code you are developing, you will need images of fluorescent microspheres. One way to get some images is to go to the lab, snap a few pictures with your microscope, and use those for testing. This is a fine idea, and you ought to do just that. But there is a drawback to this approach: the microspheres are scattered randomly so you don't know the ground truth of where the microspheres are. How will you know if you got it right? Another good approach is to generate synthetic images of microspheres whose positions you know exactly. The drawback of synthetic images is that thewy may differ in some important way from the actual images that come out of your microscope. It's a good idea to test your code both ways. |
Before you start working on your resolution and particle tracking code, let's get started by generating synthetic images. | Before you start working on your resolution and particle tracking code, let's get started by generating synthetic images. |
Revision as of 19:31, 28 September 2017
Overview
All software has to be tested. The code you will develop for this part of the lab measures the size and position of fluorescent microspheres in images. To test the code you are developing, you will need images of fluorescent microspheres. One way to get some images is to go to the lab, snap a few pictures with your microscope, and use those for testing. This is a fine idea, and you ought to do just that. But there is a drawback to this approach: the microspheres are scattered randomly so you don't know the ground truth of where the microspheres are. How will you know if you got it right? Another good approach is to generate synthetic images of microspheres whose positions you know exactly. The drawback of synthetic images is that thewy may differ in some important way from the actual images that come out of your microscope. It's a good idea to test your code both ways.
Before you start working on your resolution and particle tracking code, let's get started by generating synthetic images.
A useful function: draw a particle
The function below is a useful building block. It draws a single particle on a dark background. To make an image of multiple particles, you can add up the images of several individual particles. You will get funny results if the particles overlap. The function returns a two-dimensional array of doubles. You can specify the location of the particle, its radius, and its intensity as well as the size of the image.
function OutputImage = DrawOneFluorescentMicrosphere( YCenter, XCenter, Radius, Intensity, ImageSizeY, ImageSizeX ) [ x, y ] = meshgrid( 1:ImageSizeX, 1:ImageSizeY ); distanceFromParticleCenterPixels = hypot(x - XCenter, y - YCenter); distanceFromParticleCenterRadiuses = distanceFromParticleCenterPixels ./ Radius; mask = ( distanceFromParticleCenterRadiuses < 1 ); OutputImage = Intensity .* mask .* cos( distanceFromParticleCenterRadiuses .* pi ./ 2 ); end
Remember that MATLAB functions have to be stored in a file that has the same name as the function, appended with ".m" Give the function a try ... type something like: imshow( DrawOneFluorescentMicrosphere( 100, 100, 30, 1, 200, 200 ) ); . Play around with the arguments a bit. It's fun.
Modeling optical resolution
function OutputImage =