Two solutions were found by my students to display the histogram of a grayscale (or indexed) image.
The first solution is a code written by Jeric
//Jeric Tugaff
//Histogram
im=imread('grayscale.jpg'); //opens a 24 bit image
im=im(:,:,1);imwrite(im(:,:), 'gs.jpg'); //converts to 8 bit grayscale
imageim=imread('gs.jpg');
val=[];
num=[];
counter=1;
for i=0:1:255
[x,y]=find(im==i); //finds where im==i
val(counter)=i; num(counter)=length(x); //find how many pixels of im have value of i
counter=counter+1;end
plot(val, num); //plot. :)
The second was found by Jorge, a built-in function
histplot([0:1:255],c);
where c is the image variable.
Deposited in this blog are snippets of technical knowledge i'd like to refer back to from time to time.
Tuesday, June 24, 2008
Saturday, June 14, 2008
Collective comments on Activity 1 AP 186
AP 186 08-09 Class:
Most of you got the technique right. 10 point for those with correct reconstruction. 11 points for those with convincing overlays. There are a few who forgot the following important details, though:
1. The journal source - a number of you didn't cite what journal and paper they got the graphs from.
2. Collaborators - some of you forgot to mention who helped you. Please tell if you did it independently. Part of the learning is learning from each other. If you're not certain, ask around. If you're certain, share.
3. Details on how you got your graphs - some of you had no explanations.
4. Self-evaluation - remember you give your grade. If i think you got lower or higher than what you deserve I'll change it.
Most of you got the technique right. 10 point for those with correct reconstruction. 11 points for those with convincing overlays. There are a few who forgot the following important details, though:
1. The journal source - a number of you didn't cite what journal and paper they got the graphs from.
2. Collaborators - some of you forgot to mention who helped you. Please tell if you did it independently. Part of the learning is learning from each other. If you're not certain, ask around. If you're certain, share.
3. Details on how you got your graphs - some of you had no explanations.
4. Self-evaluation - remember you give your grade. If i think you got lower or higher than what you deserve I'll change it.
Sunday, March 2, 2008
Progressive scan camera ideal for image processing
Choose a progressive scan camera for detail-sensitive research applications. Interlaced cameras suffer from twitter and must be de-interlaced. De-interlacing causes blurring in output image. On the other hand, progressive scan cameras will send signals "progressively", as in horizontal line per line and not alternatingly.
Wednesday, February 27, 2008
Saturday, February 23, 2008
Reading "dates and time" in Matlab
If given a .txt data file with date entries enclosed in "quotes", open in xls and save as .csv. In Matlab call with textread and for the column corresponding to the date, use the format %q.
Counting the incidence of a name
In OpenOffice spreadsheet, suppose I want to count how many times a name appears, I found that one can use the countif function with the following syntax:
=countif( <range of cells to look at>;"="&<pattern>)
can be
"Name"
or
a cell such as
F65.
Caveat: This function is very strict with pattern matching. A space at the end of the name will result in no match so be careful.
=countif( <range of cells to look at>;"="&<pattern>)
"Name"
or
a cell such as
F65.
Caveat: This function is very strict with pattern matching. A space at the end of the name will result in no match so be careful.
Subscribe to:
Posts (Atom)