1.0

1.0 | 2 ratings Rate this file 5 Downloads (last 30 days) File Size: 1.69 KB File ID: #25929
image thumbnail

'c' language style code for dilation

by Rama Chandra Rao Naradasu

 

23 Nov 2009 (Updated 25 Nov 2009)

A 'c' style code for dilation

| Watch this File

File Information
Description

In this initially the color image is thresholded an then the dilation operation applied

MATLAB release MATLAB 7 (R14)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (7)
23 Nov 2009 Anon

Uuuh (shudder)... there are so many shortcomings that I just don't know where to start...

1. it's a script and not a function
2. uses clc and clear all at the beginning
3. tries to read an image that has not been supplied with the submission (dil.jpg)
4. unnecessary use of nested loops
5. no preallocation
6. no comments
7. no help
8. tries to index in variables that have not been created before
9. and so on...

Please remove.

24 Nov 2009 Rama Chandra Rao Naradasu

Friends it is a general code which is written using the c language method.
- I used the only rgb2gray() function to convert RGB image to grayscale image.
- I just used 'clc' & 'clear all' to clear the main screen & to watch only the output of my program.
- Please remember that 'dil.jpg' image is used by me if u r familiar with matlab programming change 'dil.jpg' to ur own image.
- It is not possible to apply dilation on binary image without these loops.(Please note it). There is nothing unnecessary there is a need for using those loops.
-There is no need for preallocations.

I didn't gave clear help and comments that is the problem with the code...............
I will check it.

24 Nov 2009 Jos (10584)

As long as you
- do not know how to optimize codes like this (in matlab, not in C!)
% -- begin of code --
for i=1:a
    for j=1:b
        y(i,j)=0;
        dia(i,j)=0;
     end
end
% -- end of code --

- do not know the advantages of pre-allocation
- do not the difference between functions and scripts
- uses clc and clear all without a good reason

your function is rather useless to others ...

24 Nov 2009 Bruno Luong

Matlab programming requires different approach and style than C programming. I suggest the OP to consider seriously the two comments the code has received and I hope he will improve his code.

25 Nov 2009 Anon

This function might be useful for others who want to learn how NOT to code in Matlab. Is this your intention?

26 Nov 2009 Su Dongcai

Dear Rama Chandra Rao Naradasu:
  I think it would be better if you coded it using "mexfunction" in 'c' or 'c++' type, it would be a good demonstration of how imdilate work.

11 Jan 2010 Rob Campbell

You should provide the example image. People are unlikely to investigate your function at all unless you do this. Personally, I don't have a suitable image lying around. You clearly have one, so it should be included.

You shouldn't have the clc there. The user might not want their screen cleared and it isn't need for your code.

This should be a function. The reason is that functions will run faster than scripts in Matlab. I believe those with many loops will see a particularly large speed improvement.

Please login to add a comment or rating.
Updates
24 Nov 2009

I didn't updated the code but I added comments clearly for each step.......

25 Nov 2009

I didn't updated the code but changed the view of downloaders.

25 Nov 2009

just changed comments

Tag Activity for this File
Tag Applied By Date/Time
image processing Rama Chandra Rao Naradasu 23 Nov 2009 10:52:21

Contact us at files@mathworks.com