function [eMem,imgPlus,memimg,u,out]=memEdge(oriimg,tf,dtime,I)
%
% Philip Tsai's improved Canny's Edge Detector using his membrane-difference 
% method.
%
% Usage: [edgeMap, enhancedImg, membrane, originalImg, cnnOutput]=
%        memEdge(imageFile, tFinal, displayTime,I);
%
% <Output parameters>
% edgeMap:     the resultant edge map;
% enhancedImg: the enhanced image;
% membrane:    the membrane;
% originalImg: the original image in CNN's intensity range ([-1,1]);
% cnnOutput:   the difference between membrane and originalImg minus 1.
%
% <Input parameters>
% Please see membrane.m for explanation of the input parameters.
%

if nargin < 4, I = -1.0; end
if nargin < 3, dtime = 1; end
if nargin < 2, tf = 10; end

figure;
[memimg,u,out]=membrane(oriimg,tf,dtime,I);
imgPlus=u-out;

figure;imagesc(imgPlus);colormap(gray);title('enhancedImg'); 
eMem=edge(imgPlus,'canny');
figure;imshow(eMem);title('eMembrane');

%figure;imagesc(oriimg);colormap(gray);title('oriimg');
%eOri=edge(oriimg,'canny');
%figure;imshow(eOri);title('eCanny');


