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.
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.
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.
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.
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
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.
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.
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.
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 ...
Comment only