3

Hi all I am currently trying to use the SMMT operator of the paper "Multiscale Morphological Image Simplification" at Dorini. Since the page cannot be accessed without subscription, I am posting the relevant details here:

enter image description here enter image description here enter image description here

Please Note that I am posting parts of the relevant article as images. I do not know how to write equations in stackoverflow.com. I want to use this SMMT operator as a pre-processing step in image processing. The code that I have written down is given below:

clc;clear all;close all;
tic
I=imread('handwritten.jpg');
I=I(:,:,1);

dim=11 ;
HEIGHT=zeros(dim,dim);
sigma=1/10;
for i=-floor(dim/2):floor(dim/2)
    for j=-floor(dim/2):floor(dim/2)
       HEIGHT(i+ceil(dim/2),j+ceil(dim/2))=-(1/sigma).*max(abs(i),abs(j));
    end
end
NHOOD=ones(dim,dim);
se = strel('arbitrary',NHOOD,HEIGHT);
se

IM1 = imdilate(I,se,'same');
IM2 = imerode(I,se,'same');
figure;
subplot(2,2,1),imshow(I)
subplot(2,2,2),imshow(IM1)
subplot(2,2,3),imshow(IM2)

II = I;
for i=1:1
    phi1 = imdilate(II,se,'same');
    phi2 = imerode(II,se,'same');
    for j=1:size(I,1)
        for k=1:size(I,2)
            if ((phi1(j,k)-II(j,k))<(II(j,k)-phi2(j,k)))
                II(j,k) = phi1(j,k);
            elseif ((phi1(j,k)-II(j,k))==(II(j,k)-phi2(j,k)))                
                II(j,k) = II(j,k);
            else
                II(j,k) = phi1(j,k);
            end
        end
    end
end
IM3=II;
subplot(2,2,4),imagesc(IM3,[0 255]);colormap('gray');axis off;
toc

The result of the code should be something like this : (again from paper): enter image description here.

My result is this:- enter image description here.

Is my implementation correct?? Can it be improved further ?? Any suggestions will be helpful. Thanks in advance for your help guys!! For more details refer to Dorini Free Access

beedot
  • 652
  • 5
  • 12
roni
  • 1,443
  • 3
  • 28
  • 49
  • why do you think your implementation is not correct? do you have a **specific** problem/question? SO is not for code review. You might consider posting at: http://codereview.stackexchange.com. – Shai Jan 06 '14 at 07:10
  • 1
    This question appears to be off-topic because it is a request for code review and more suitable for http://codereview.stackexchange.com/ – Shai Jan 06 '14 at 07:10

1 Answers1

0

The implementations looks ok globally, a small clarification though:

if ((phi1(j,k)-II(j,k))<(II(j,k)-phi2(j,k)))
                II(j,k) = phi1(j,k);

I guess here you would like to change the image value in variable II while comparing phi1 and I:

if ((phi1(j,k)-I(j,k))<(I(j,k)-phi2(j,k)))
                II(j,k) = phi1(j,k);
Shai
  • 111,146
  • 38
  • 238
  • 371
beedot
  • 652
  • 5
  • 12