function [R] = RotateIm(A,angle)
A=padarray(A,[50,50]);
angle=-angle*pi/180; %to make the positive rotate clock wise like required
Tinv=[cos(angle) sin(angle);-sin(angle) cos(angle)];
R=zeros(size(A,1),size(A,2));
px=(size(A,1))/2;
py=(size(A,2))/2;
for m = 1:size(A,1)-1
for n = 1:size(A,2)-1
x=Tinv*[m-px;n-py]+[px;py];
I=floor((x(1,1)));
K=floor((x(2,1)));
a=x(1,1)-I;
b=x(2,1)-K;
% R(m,n)=R(m,n)+(1-a)*(1-b)*A(I,K)+a*(1-b)*A(I+1,K)+(1-a)*b*A(I,K+1)+a*b*A(I+1,K+1);
if(I>=1&&I<=size(A,1)&&K<=size(A,2) && K >=1 )
R(m,n)=R(m,n)+(1-a)*(1-b)*A(I,K);
end
if(I<size(A,1)&&I>=1 && K >=1 && K <= size(A,2))
R(m,n)=R(m,n)+ a*(1-b)*A(I+1,K);
end
if(I>=1 && I<=size(A,1) && K >=1&& K < size(A,2) )
R(m,n)=R(m,n)+ (1-a)*b*A(I,K+1);
end
if(I<size(A,1) &&I>=1&&K>1&& K < size(A,2) )
R(m,n)=R(m,n)+ a*b*A(I+1,K+1);
end
end
end
[MaxRow,MaxCol] = find(R,1,'last');
[MinRow,MinCol] = find(R,1,'first');
R=R(min(MinRow,MinCol):max(MaxRow,MaxCol),min(MinRow,MinCol):max(MaxRow,MaxCol));
R=uint8(R);
end
ITknowledgeCenter
Thursday, April 30, 2015
Integral Image Algorithm
function [II] = IntegIm(A)
A=double(A);
s=double(zeros(size(A,1)+1,size(A,2)+1));
II=double(zeros(size(A,1)+1,size(A,2)+1));
for m = 2:size(A,1)+1
for n = 2:size(A,2)+1
s(m,n)=double(s(m,n-1) + A(m-1,n-1));
end
end
for m = 2:size(s,1)
for n = 2:size(s,2)
II(m,n)=double(II(m-1,n)+s(m,n));
end
end
end
A=double(A);
s=double(zeros(size(A,1)+1,size(A,2)+1));
II=double(zeros(size(A,1)+1,size(A,2)+1));
for m = 2:size(A,1)+1
for n = 2:size(A,2)+1
s(m,n)=double(s(m,n-1) + A(m-1,n-1));
end
end
for m = 2:size(s,1)
for n = 2:size(s,2)
II(m,n)=double(II(m-1,n)+s(m,n));
end
end
end
Saturday, April 25, 2015
IBM BPM Coach Validation Example
1-Create Human Service with name "testValidate"
2-Create Private Variable "text"
3-add coach to the human service name it "testvalidation"
4-add text coach and bind it to the text variable
5-select the path from the TestValidation coach to the end event and then change fire validation setting to before then add a server script named "ValidationScript" and connect it like the screen shot
6-add server script and put the following code in it
if(tw.local.text=="bpm")
{
tw.system.addCoachValidationError(tw.system.coachValidation, "tw.local.text", "error in validation")
}
7- run the human service and write bpm at the screen shot then click ok you will see that the validation is fired
3-add coach to the human service name it "testvalidation"
4-add text coach and bind it to the text variable
5-select the path from the TestValidation coach to the end event and then change fire validation setting to before then add a server script named "ValidationScript" and connect it like the screen shot
6-add server script and put the following code in it
if(tw.local.text=="bpm")
{
tw.system.addCoachValidationError(tw.system.coachValidation, "tw.local.text", "error in validation")
}
7- run the human service and write bpm at the screen shot then click ok you will see that the validation is fired
Tuesday, April 21, 2015
Matlab Implementation for SIFT "Scale-invariant feature transform "
Scale-invariant feature transform (or SIFT) is an algorithm in computer vision to detect and describe local features in images.
function [outImage,keypoints] = my_sift(A,maxS,t)
if (~exist('t', 'var'))
t=0;
end
if(size(A, 3)>1)
A=rgb2gray(A);
end
m=1;
sigmas=(1:1:maxS);
%A=padarray(A,[1,1]);
A=double(A);
keypoints=zeros(size(A,1)*size(A,2),4);
logImages=zeros(size(A,1),size(A,2),size(sigmas,2));
t=t*max(max(A));
for k=1 :size(sigmas,2)
h=sigmas(1,k)*sigmas(1,k)* fspecial('log', 2*ceil(3*sigmas(1,k))+1,sigmas(1,k));
logImages(:,:,k)= imfilter(A,h);
end
for i=2 :size(A,1)-1,
for j=2:size(A,2)-1,
isKeypoint=1;
[maxVal,maxInd]=max(abs(logImages(i,j,:)));
if(maxInd~=1 && maxInd~=maxS)
for q=(i-1):i+1
for w=(j-1):j+1
if(abs(logImages(i,j,maxInd))<(t*maxInd*maxInd)|| abs(logImages(i,j,maxInd))< abs(logImages(q,w,maxInd-1))||abs(logImages(i,j,maxInd))< abs(logImages(q,w,maxInd))||abs(logImages(i,j,maxInd))< abs(logImages(q,w,maxInd+1)))
isKeypoint=0;
break;
end
end
if(isKeypoint==0)
break;
end
end
else
isKeypoint=0;
end
if(isKeypoint==1)
keypoints(m,1)=j;
keypoints(m,2)=i;
keypoints(m,3)=sqrt(2)*sigmas(1,maxInd);
keypoints(m,4)=sigmas(1,maxInd);
m=m+1;
end
end
end
%yellow = uint8([255 255 0]);
%shapeInserter = vision.ShapeInserter('Shape','Circles','BorderColor','Custom','CustomBorderColor',yellow,'LineWidth',0.1);
A=uint8(A);
outImage=A;
keypoints= keypoints(1:min(find(keypoints==0))-1,1:4);
%RGB = repmat(A(2:size(A,1)-1,2:size(A,1)-1),[1,1,3]); % convert I to an RGB image
for b=1:size(keypoints,1) %min(find(keypoints==min(keypoints,1)))
outImage = insertShape(outImage, 'circle',keypoints(b,1:3) );
end
%yellow = uint8([255 255 0]);
%shapeInserter = vision.ShapeInserter('Shape','Circles','BorderColor','white');
%RGB = repmat(A,[1,1,3]);
%outImage = step(shapeInserter, A(2:size(A,1)-1,2:size(A,1)-1), keypoints);
end
function [outImage,keypoints] = my_sift(A,maxS,t)
if (~exist('t', 'var'))
t=0;
end
if(size(A, 3)>1)
A=rgb2gray(A);
end
m=1;
sigmas=(1:1:maxS);
%A=padarray(A,[1,1]);
A=double(A);
keypoints=zeros(size(A,1)*size(A,2),4);
logImages=zeros(size(A,1),size(A,2),size(sigmas,2));
t=t*max(max(A));
for k=1 :size(sigmas,2)
h=sigmas(1,k)*sigmas(1,k)* fspecial('log', 2*ceil(3*sigmas(1,k))+1,sigmas(1,k));
logImages(:,:,k)= imfilter(A,h);
end
for i=2 :size(A,1)-1,
for j=2:size(A,2)-1,
isKeypoint=1;
[maxVal,maxInd]=max(abs(logImages(i,j,:)));
if(maxInd~=1 && maxInd~=maxS)
for q=(i-1):i+1
for w=(j-1):j+1
if(abs(logImages(i,j,maxInd))<(t*maxInd*maxInd)|| abs(logImages(i,j,maxInd))< abs(logImages(q,w,maxInd-1))||abs(logImages(i,j,maxInd))< abs(logImages(q,w,maxInd))||abs(logImages(i,j,maxInd))< abs(logImages(q,w,maxInd+1)))
isKeypoint=0;
break;
end
end
if(isKeypoint==0)
break;
end
end
else
isKeypoint=0;
end
if(isKeypoint==1)
keypoints(m,1)=j;
keypoints(m,2)=i;
keypoints(m,3)=sqrt(2)*sigmas(1,maxInd);
keypoints(m,4)=sigmas(1,maxInd);
m=m+1;
end
end
end
%yellow = uint8([255 255 0]);
%shapeInserter = vision.ShapeInserter('Shape','Circles','BorderColor','Custom','CustomBorderColor',yellow,'LineWidth',0.1);
A=uint8(A);
outImage=A;
keypoints= keypoints(1:min(find(keypoints==0))-1,1:4);
%RGB = repmat(A(2:size(A,1)-1,2:size(A,1)-1),[1,1,3]); % convert I to an RGB image
for b=1:size(keypoints,1) %min(find(keypoints==min(keypoints,1)))
outImage = insertShape(outImage, 'circle',keypoints(b,1:3) );
end
%yellow = uint8([255 255 0]);
%shapeInserter = vision.ShapeInserter('Shape','Circles','BorderColor','white');
%RGB = repmat(A,[1,1,3]);
%outImage = step(shapeInserter, A(2:size(A,1)-1,2:size(A,1)-1), keypoints);
end
Monday, April 20, 2015
Custom Exception Message Using Out of the box Exception in IBM BPM
to catch exception using out of the box intermediate event get the message from tw.system.error using the following Xpath expression
tw.local.error=tw.system.error.xpath("/error/localizedMessage").item(0).getText();
and here is the output
and here is the used human service to demonstrate this in the sql service i tried to access www table which is not in the Database
tw.local.error=tw.system.error.xpath("/error/localizedMessage").item(0).getText();
and here is the output
and here is the used human service to demonstrate this in the sql service i tried to access www table which is not in the Database
Saturday, April 18, 2015
Matlab Implementation For Average Filter Using Integral Image
function [Filtered_image] = AverageFilter(A,s)
%S should be odd if s is even will increment by 1
%size of the filter is sxs
if(rem(s,2)==0 && s>1)
s=s+1;
end
II=integralImage(A);
x=zeros(size(II,1),size(II,2));
for m = 2:size(A,1)
for n = 2:size(A,2)
if((m+floor(s/2))<=size(II,1)&&(n+floor(s/2))<=size(II,2))
x(m,n)=x(m,n)+II(m+floor(s/2),n+floor(s/2));
end
if((n-floor(s/2)-1)>=1&&(m-floor(s/2)-1)>=1)
x(m,n)=x(m,n)+II(m-floor(s/2)-1,n-floor(s/2)-1);
end
if((m-floor(s/2)-1)>=1&&(n+floor(s/2))<=size(II,2))
x(m,n)=x(m,n)-II(m-floor(s/2)-1,n+floor(s/2));
end
if((m+floor(s/2))<=size(II,1)&&(n-floor(s/2)-1)>=1)
x(m,n)=x(m,n)-II(m+floor(s/2),n-floor(s/2)-1);
end
x(m,n)=round((x(m,n)/(s*s)));
end
end
Filtered_image= uint8(x(2:size(x,1),2:size(x,2)));
end
%S should be odd if s is even will increment by 1
%size of the filter is sxs
if(rem(s,2)==0 && s>1)
s=s+1;
end
II=integralImage(A);
x=zeros(size(II,1),size(II,2));
for m = 2:size(A,1)
for n = 2:size(A,2)
if((m+floor(s/2))<=size(II,1)&&(n+floor(s/2))<=size(II,2))
x(m,n)=x(m,n)+II(m+floor(s/2),n+floor(s/2));
end
if((n-floor(s/2)-1)>=1&&(m-floor(s/2)-1)>=1)
x(m,n)=x(m,n)+II(m-floor(s/2)-1,n-floor(s/2)-1);
end
if((m-floor(s/2)-1)>=1&&(n+floor(s/2))<=size(II,2))
x(m,n)=x(m,n)-II(m-floor(s/2)-1,n+floor(s/2));
end
if((m+floor(s/2))<=size(II,1)&&(n-floor(s/2)-1)>=1)
x(m,n)=x(m,n)-II(m+floor(s/2),n-floor(s/2)-1);
end
x(m,n)=round((x(m,n)/(s*s)));
end
end
Filtered_image= uint8(x(2:size(x,1),2:size(x,2)));
end
Friday, April 17, 2015
Using Dojo Chart Toolkit For Custom Reports in IBM BPM
The
following to steps show how to use the Dojo Charts Toolkit to make custom
reports
This
example is implemented on the Hiring
Request Process
Step1: download and import the dojo toolkit from this link
http://wiki.bpmwiki.com/display/samples/BPM8+Dojo+Chart+Toolkit#BPM8DojoChartToolkit-DownloadPackage
Step2:open the dojo chart process app in the process
designer this is a process application that has some examples on how to use the
charts
Step3:copy the following items to the process application in which
you want to use the chart and develop the reports
Step4:open the Sample human Service in the configure chart script
put the labels that will appear on axis of the chart. The other axis will be
filled by data entries for series as will be shown in step 9
|
for example this report for number of employees
at each region per department so each
region is considered as a label “west,east,north,south”
Step5: In the coach put a bar chart control or a pie chart whatever
you want to try
Step6:in the view make sure that you choose the basic bar control
you copied from the Dojo Chart process application
Step7: open the basic chart default AS
Step8: in the Initialize Linear step put the departments you want
to report
Step10:Run the
sample human service this should be the final output
Subscribe to:
Posts (Atom)