Matlab program files for random fields and images
General
-
instructions
contains very simple Matlab instructions
-
allfiles.tar contains all Matlab and image files
currently in this directory. You should read the directions
for downloading. It is a good idea to download this each time
you use these files, since some of the programs here use other programs
not listed here.
-
In the recent versions of Matlab, you can rotate 3d graphs (and 2d graphs)
by entering the command "rotate3d on" and then clicking and dragging on
the graph. You can see how the axes will change, and when you let
up on the mouse button, the graph moves to the new orientation. In
Matlab 6, pull down the Tools menu on the graph window and select Move
Camera. Then, when you click and drag on a graph, you see the graph
itself rotate.
Loading images and making simple modifications
Note to BGSU users: the version of Matlab available in the Scientific Computing
Lab does not have the image processing toolbox installed, and so cannot
be used to run the image processing example program below.
-
Here are some basic directions
for scanning things in Room 401 and the Scientific Computing Lab, plus
information
on image formats like GIF, JPG, PNG, BMP, and more.
-
Here is a brief description of the types
of images in Matlab
-
Matlab has built-in demonstrations; run ipexindex
-
trigimage.m displays an intensity plot of a trig
field as an image, as a way of understanding the differences between matrices
and images. Then it changes the colormaps.
-
simpleRGBimage.m manually specifies intensities
in an image
-
simpleRGBimage2.m manually specifies intensities
as uint8
-
party.m reads a file, displays it and its red, green,
and blue components
-
trigfield2A.m turns an evolving trig field
into a movie
-
clown_treesBW.m loads, converts to grayscale
(intensity image) and displays two Matlab images. It shows how to do simple
modifications such as brightening, reverse video, superimposition, flipping,
and blurring. It also makes a graph of the gray-scale intensity as a surface
and contour graph. Page 1.
-
thresh.m converts an image to black and white using
threshholds
-
edges.m illustrates Matlab edge detection methods
Image modeling
-
isingminimum.m tries to minimize the Ising
energy pixel by pixel
-
isingminmac.m tries to minimize the Ising energy
pixel by pixel; for the Macintosh.
-
grapple1.m loads and displays grapple.gif,
then performs median filtering. Output
-
grapple2.m applies median filters until no further
change occurs
-
grapple3.m applies median filters with succesively
larger windows
-
party_gray.m reads a grayscale version of party_72.png
and displays it. It is appropriate for Matlab on the Macintosh's
at BGSU.
-
Generating realizations of random fields
-
iidfield1.m generates and graphs a matrix of
iid variables. Output
-
iidfield2.m generates, smooths, and graphs a
matrix of iid variables. Out1Out2
Out3Out4
Out5
-
trigfield1.m generates wave numbers and amplitudes
and graphs a random field. Output
-
trigfield2.m generates wave numbers and amplitudes
which evolve over time
-
trigfield3.m generates wave numbers with a preferred
direction. Output
-
trigfield4.m makes it easy to zoom in on part
of a field. To use it, first set keep = 0, run trigfield4, then set
keep = 1 and gridrange=[xmin xmax ymin ymax]. Then run trigfield4
again.
-
trigfield5.m investigates the distribution of
F(0). Output
-
trigfield6.m investigates the joint distribution
of F(0,0) and F(x,y). Output
-
trigfield7.m allows you to explicitly choose
wavenumbers. Output
-
trigfield8.m generates field values at random
locations. Output
-
trigfield9.m computes the covariance associated
with a given way of generating random wave numbers. Output
-
trigfield10.m computes the covariogram for
a given way of generating the norms of isotropic two-dimensional wave numbers.
Output
-
trigfield11.m displays a trig field using several
different scales
-
covariogram1.m uses data to produce a sample
covariogram.
-
covariogram2.m generates field values, computes
a sample covariogram, and compares to the actual covariogram
-
ou1.m simulates Ornstein-Uhlenbeck by inverting the
covariance matrix
-
kriging1.m generates field values at various locations,
then predicts values at other locations using the known covariance
-
kriging2.m generates field values at various locations,
predicts values at other locations using the known covariance, and compares
to Matlab's interpolation routine griddata
-
cells.m generates Poisson patches of different colors
-
bumps.m generates a field with bumps centered at
Poisson points
A gray-scale image is just a special graph of a function of two variables
that takes values between 0 and 1. The graph is white where the function
equals 1, it is black where the function is 0, and is various shades of
gray for intermediate values. It can be manipulated like any other function,
and you can add or average two different images, as you would add or average
two functions. In practice, the image data is stored in a matrix whose
entries are numbers between 0 and 1. For the examples loaded in the file
images.m below, the matrices are 200 by 320. Color images are not much
different. They simply have 3 functions (or matrices), one showing the
red intensity, one for blue, and one for green.