« Project #Syllabus for all sect | Main | Homework Syllabus for all sect »
January 26, 2006
VisualStuSyllabus for all sect
I had some time this morning so I thought I'd finish up my version of Project 1. For those of you who haven't finished already, which is a small subset of the class I am sure, I thought I'd put together some tips and tricks I found along to way. This might save you some time learning the IDE and the language. I am using this file distribution (mirror at faculty.cs.byu.edu)The most important thing you should know is that my implementation isn't even close to 10 seconds. se we are going to visit that part of the project requireument this afternoon in TA meeting look for an announcement around 5pm about the performance requireument for this lab.
- To find out where a field or method is declared, right click on the name and then select "goto definition" it is the fourth item down on my setup.
- You'll want to code up your naive greedy and Dijkstra scissors in the classes DijkstraScissors and SimpleScissors. These are classes that implement the abstract Scissors class. The Scissors class includes an Overlay field. This Overlay field is what you'll do your drawing upon. The Overlay field is a bitmap and has a SetPixel method that you can use to set pixels.
- The Bitmap class gives you raster based graphics. That is, you can set individual pixels. Raster based graphics are good for setting pixels, but if you want to draw a line then you have to rasterize the line by figuring out the equation for the line (think slope-intercept form) and then setting the right pixels. You can also use vector-based graphics. To use vector based graphics, you need a Graphics object. To see an example of a Graphics object created from the image Overlay, visit lines 10-25 ish of StraightScissors.cs. Once you have a Graphics object, you can draw all many of lines, circles etc.
- The segmentation points are passed in using an IList class. The IList class methods and properties are well documented using the Help facilities. Basically, it works like an array. See StraightScissors.cs for an example.
- If you set the color of a Pixel in the Overlay, but you aren't seeing your pixel change colors in the image, then you probably aren't telling the top-level form to refresh and redraw. This requires...
Program.MainForm.RefreshImage();
where RefreshImage is a class in the file distribution (and nSyllabus for alPosted by jones at January 26, 2006 09:22 AM
Comments
Your file distribution link is broken.
Posted by: Andrew Arnott
at January 26, 2006 01:20 PMHmm. that's lame. Now fixed. Thanks.
Posted by: Mike Jones
at January 26, 2006 02:09 PMI couldn't find any references to an Overlay field in the scissors class from your linked distribution.
Posted by: Scott Paul Robertson
at January 26, 2006 04:48 PMAlso GetPixelWeight(Point p) doesn't exist in the distribution. I'm feeling rather confused as to what I actually have to implement.
Posted by: Scott Paul Robertson
at January 26, 2006 06:24 PMScott,
You should see it in Scissors.cs The DijkstraScissors.cs class is a subclass of Scissors.cs and Scissors.cs contains GetPixelWeight (it is on about line 38). Note that it is protected in Scissors.cs so you might have to work around that.
When did you download the files you are working
with?You need to implement the method Trace in DijkstraScissors.cs and the Trace method in SimpleScissors.cs
Hope that helps,
mike.Posted by: Mike Jones
at January 26, 2006 06:55 PMDr. Jones,
I have just downloaded the said files, and it doesn't contian the GetPixelWeight() function in the scissors.cs, or the other things in the main post of this blog. It's the same distribution was available last Monday.Posted by: drfindley
at January 26, 2006 06:59 PMDrfindley and Scott,
Thanks for pointing that out. I was indeed one distro stale. I've copied the latest and greatest up to the server so that comments here and the files you get will match up better. I even included a comment about where to implement stuff in DijkstraScissors.cs and SimpleScissors.cs
Note that this distribution actually gives you some of what the project description says you were supposed to implement (like the code to parse the segmentation points out of the images and the GetPixelWeight() function). So it should make your lives a litte easier.
Mike.
Posted by: Mike Jones
at January 26, 2006 08:19 PMOkay, this makes sense now. Are all the other optimized files that were posted previously included now?
Posted by: Mortlath
at January 26, 2006 08:31 PMMortlath,
Yes. this is the fully tricked out framework in which you can implement your algorithm.
Posted by: Mike Jones
at January 26, 2006 09:51 PMFrom the spec:
"setPixel (x: int, y:int, gray:int) sets pixel x,y to gray value gray. In the distributed code, this is a blatant violation of model-view-controller that will actually cause your algorithm to perform incorrectly. So change it (but you don’t have to go all the way to pure model-view-controller if you don’t have the time or inclination.)"
It looks like this method no longer exists.
Posted by: Mortlath
at January 26, 2006 10:19 PMMortlath,
Thank you. The writeup got out of sync with the files. You'll want to do
Image.Bitmap.SetPixel(int x, int y, Color c)
I'll tweak the writeup.
Mike.
Posted by: Mike Jones
at January 26, 2006 10:24 PMI'll want to do what with it?
Should I abstract it into a method in the Scissors class?
Posted by: Mortlath
at January 26, 2006 10:31 PMYou can abstract it if you want, but you should be able to just use that line of code anywhere you want to in your [Dijkstra|Simple]Scissors class because Image is accesible in the abstract class implemented by both of these classes.
Let me know if that doesn't work, and while you are at it the project description has been updated...
Posted by: Mike Jones
at January 26, 2006 10:50 PMSo we don't have to change "this is a blatant violation of model-view-controller"? That's fine with me.
Also, about the "Simple Greedy" Scissors, if all nodes are weighted equally, does it just choose arbitraily or should it seek the end point? Right now, mine just goes off and backs itself into a corner.
Posted by: Mortlath
at January 26, 2006 11:06 PMThe blatant violation of model-view-controller is ok.
If all adjacent nodes are weighted equally then you can use either strategy. the point here is to see that the simple greedy algorithm has poor performance. I think you've accomplished that objective and are free to move on.
Mik.e
Posted by: Mike Jones
at January 27, 2006 07:56 AMPost a comment
Thanks for signing in, . Now you can comment. (sign out)
(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)