0

To be honest, thats the exact opposite of what you should be doing. To keep code managable and readable its better to split it up into distinct classes and methods. By throwing everything into a singel method it makes it very hard to track down errors or make changes to parts of the code (as you are finding out now). You woul dbe better to write a class that handles the functionality, pass the image to it and have it return the resulting image. Then inside that class you split up the process into distinct methods.

I'll go over the code in your project and see if i cant hash it together into a more OO friendly structure for you :)

0

Well frankly, that is what I had done. But as I had mentioned to you, this is for a project and I need to implement each filter as a single class, however complex it maybe. Kinda dumb but cant help it.

0

DO you mean one class containing all filters, or each filter in a seperate class?

If you have been told to put all of the filters into a single class i would suggest you check with whoever set you the task because either a) there has been some miscommunication and you are approaching this incorrectly or b) they have some very odd views on software development.

This is a clear example of where OO works, each filter is a distinct process so you put it in its own class. Instantiate class, feed in image, get back filtered image.

Are you sure you arent supposed to have a single class which is responsible for loading each filter class and passing the image through them one by one?

0

I think you have misunderstood me.. Each filter is in a separate class under one project. What I am doing right now has two separate filters, which are in two separate classes. The execute() function calls the other class and performs the reqd operations.

Its more like I have a main form where I can choose what operation I wish to perform. Depending on what I choose, the corresponding filter class is accessed.

0

In that case you have the right idea :)

Is RegionClassification one of the filter classes? I could see similarities between that and the watershed class but they had different code so i wasnt sure if they were seperate filters or if you had combined several filters into the same method

0

Ya RegionClassification is one of the filter classes. Like you said, the code is somewhat similar, but both have different functionalities..

0

aaah, i see. That is what confused me, i assumed you were merging the filters into one which is counterproductive :)
I'll take another look in the light of this fresh perspective ;)

0

Sure. Meanwhile I am also tryin out some changes. Will let you know if I hit on something

0

i think region classification needs some attention. It hit errors in a couple of places so you might wanna have a quick scan through and check the logic is sound :)

0

yeah, u r absolutely right.. That is what i am going through.. in fact im revamping the whole code, analysing it part by part.. will let you know if i encounter something

0

Hi,

I have revamped the entire code and made a new one. It crossed the previous hurdles, but generates error in the line dstBitmapData = dstImage.LockBits(,...)

But I have not used it previously and I am unlocking it fine.

Can you tell me where the error is .. Or where I am going wrong

0

Hi, I worked around the problem and got my solution. Thing is it works fine for sometime, but after a point, I get the following error : An unhandled exception of type 'System.OutOfMemoryException' occurred in CytViewStuff1.exe..

i know it is a memory exception and c# doesnt allow you to make necessary changes to avoid this(if im rite)..

But do you have any idea what can be done

0

Hi,

im not sure how you fixed the bitlock issue, but just for clarity, the Bitmap type is a Class and therefore a reference type. So when you did dstImage = srcImage; you were simply storing a reference to srcImage. So when you tried dstImage.LockBits() you were attempting to lock srcImage, which was already locked.
Use dstImage = (Bitmap)srcImage.Clone(); if you didnt already :)

As for your memory issue, i've noticed you never reset any of your variables. For instance, you create a new list at the start but you dont empty it between images. So you keep adding more and more values to your lists, requiring more and more memory.
I'm not 100% sure, but it could be that thats causing problems. Try re-initialising your variables within your foreach(file in files) loop. Or better yet, any variables that dont need to retain a value between files can be declared inside the loop to ensure they are reset for each file and dont retain useless data.

0

Hi,

I am just back from my Christmas holidays. Thing is, before i took a vacation, my code seemed to work fine. But now its not working at all. I ve gone thru the entire thing, but am not able to figure out a problem. I am attaching the files here, can you have a look at it?

0

I know this is one dumb thing that can happen, but I am not able to find the problem

0

Hi, I worked around and got the solution working. Thanks for all the help so far

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.