Click here to Skip to main content
15,910,411 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C#
void srcn(short int** pd,int* nse,int il,int jl)
{
	int i,j,k,l;
	double std,avg,temp;
	for(i=rn;i<il-rn;i++){
		for(j=rn;j<jl-rn;j++){
			avg=0;
			temp=0;
			std=0;
			for(k=-rn;k<=rn;k++){
				for(l=-rn;l<=rn;l++){
					avg+=(double)pd[i+k][j+l];
				}
			}
			avg=avg/((double)sn*sn);
			for(k=-rn;k<=rn;k++){
				for(l=-rn;l<=rn;l++){
				temp+=((double)pd[i+k][j+l]-avg)*((double)pd[i+k][j+l]-avg);
				}
			}
			std=pow(temp/((double)sn*sn),0.5);
			if(std<c*drt){
				nse[0]++;
			}
			else{
				nse[1]++;
			}
		}
	}
	
}


What I have tried:

I want to convert this code with Python.
Posted
Updated 2-Mar-16 16:18pm
Comments
kai jia 2-Mar-16 22:09pm    
Should it convert?
Patrice T 3-Mar-16 17:16pm    
Ok, get started
kai jia 3-Mar-16 20:33pm    
Could you explain more specific?Thank you .

1 solution

Quote:
want to convert this code with Python.
thats nice .... you'd better get started then. You have two options (maybe more)

1) 'transliterate' - look at the c code, translate it to the closest Python code & write that

2) Analyse the 'functionality' of the c routine, and write that functionality from scratch in Python - there may be quicker constructs in Python that make it easier

obviously test, test, test, a large number of values to make sure what you end up with does what you want

Have fun
 
Share this answer
 
Comments
kai jia 3-Mar-16 7:36am    
Could you explain more specific in second.Thank you.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900