![]() |
| | #1 |
| Registered User Join Date: Jul 2009
Posts: 6
| Median filter help ![]() [1 2 3] [4 5 6] [7 8 9] [0 0 0 0 0] [0 1 2 3 0] [0 4 5 6 0] [0 7 8 9 0] [0 0 0 0 0] also take the median(kernel) of odd sizes, such as 3x3, 5x5, 7x7 and so on. for example, take the first nine for a 3x3 which will be: [0 0 0] [0 1 2] [0 4 5] placing the numbers of the matrix in order: (0,0,0,0,0,1,2,4,5), taking the median which in this case of a 3x3...the 5th number(0) will replace the center value 1. and then the 3x3 kernel will slide to the left one and take the median of: [0 0 0] [1 2 3] [4 5 6] and replacing the center value 2 and slide over again and repeat the sequence until all center values of the mxn matrix are replaced. I was told for loops would work but ive had no luck so far. any help would be greatly appreciated and please make comments in the steps so I can understand what each line does. Thanks -Greg Last edited by JTEK24; 07-04-2009 at 11:15 AM. |
| JTEK24 is offline | |
| | #2 |
| and the Hat of Guessing Join Date: Nov 2007
Posts: 8,740
| For each element [i,j] in the original: what are the coordinates of it's location in the new matrix? That should be all the hint you need. |
| tabstop is offline | |
| | #3 |
| Registered User Join Date: Jul 2009
Posts: 6
| They would be in the same location right? My professor told the class the same thing but we are clueless. We dont have a background in this software and we haven't taken a programing class since 4 years ago and im trying to get the for loops right but its not working. Last edited by JTEK24; 07-04-2009 at 11:42 AM. |
| JTEK24 is offline | |
| | #4 |
| and the Hat of Guessing Join Date: Nov 2007
Posts: 8,740
| Surely you can count past zero, still, though. For instance, in your original example, consider the number 4. It starts in the [1][0] spot (second row, first column). Where does it end up? Consider the number 8. It starts in the [2][1] spot. Where does it end up? |
| tabstop is offline | |
| | #5 |
| Registered User Join Date: Jul 2009
Posts: 6
| the 4 would be replaced by 2 and the 8 will be replaced by 5...i know how it computes...but actually writing the code is not making sense. |
| JTEK24 is offline | |
| | #6 |
| and the Hat of Guessing Join Date: Nov 2007
Posts: 8,740
| We're also still asking you to read English sentences. Where does the 4 go? What coordinates, in your answer matrix, will have the number four in it? (And then, how does that relate to the original coordinates.) Obviously you can't compute the number from the old number -- things are moving, not being transformed by a function. |
| tabstop is offline | |
| | #7 |
| Registered User Join Date: Jul 2009
Posts: 6
| q=9; for k = 1:q-1; b = k; for r = k+1:q; if v(r) < v(b); b = r; end end v([k,b])= v([b,k]); end how does this sort fuction work? |
| JTEK24 is offline | |
| | #8 |
| and the Hat of Guessing Join Date: Nov 2007
Posts: 8,740
| Have you traced through it on a piece of paper? (If 9 elements seems daunting, then maybe change the 9 to a 4 or so.) Watch it go, and you'll soon see how it works. |
| tabstop is offline | |
| | #9 |
| Registered User Join Date: Jul 2009
Posts: 6
| Ok, explain to me how to trace it on paper. Thats why I asked how it works so I could get an explaination. |
| JTEK24 is offline | |
| | #10 | |
| and the Hat of Guessing Join Date: Nov 2007
Posts: 8,740
| Quote:
And you keep going through the code until you get to the end. Your indentation should keep you straight on your for loops. | |
| tabstop is offline | |
| | #11 |
| Registered User Join Date: Jul 2009
Posts: 6
| Alright, Im about to write it out now. I'll post if I have further questions. |
| JTEK24 is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Please help me to convert a simple C++ program into an object-oriented one. | zekesteer | C++ Programming | 1 | 12-30-2007 10:08 AM |
| moving median function | supermeew | C Programming | 0 | 05-04-2006 02:37 PM |
| Simple Filter | 00Sven | C Programming | 3 | 03-14-2006 08:46 PM |
| Computing Mean, Median and Mode Using Arrays | Rodneo | C++ Programming | 0 | 05-29-2002 11:40 PM |
| median | frank | C++ Programming | 4 | 10-28-2001 04:32 PM |