Code:
void CLEO_MedivisionView::OnNoiseremovalMedianfilter()
{
int n=262144;
for(int x=0; x<n; x++)
{
for(int y=0; y<n-1; y++)
{
if(image[y]>image[y+1])
{
int temp = image[y+1];
image[y+1] = image[y];
image[y] = temp;
}
}
}
}
|
Go4Expert Member
|
|
| 2Nov2009,12:24 | #1 |
|
This is my code for bubble sorting:
Code:
void CLEO_MedivisionView::OnNoiseremovalMedianfilter()
{
int n=262144;
for(int x=0; x<n; x++)
{
for(int y=0; y<n-1; y++)
{
if(image[y]>image[y+1])
{
int temp = image[y+1];
image[y+1] = image[y];
image[y] = temp;
}
}
}
}
|
|
Mentor
|
![]() |
| 2Nov2009,15:10 | #2 |
|
No idea; this worked fine for me (btw: see how much clearer the code is when properly indented):
Code:
int image[262144];
void main()
{
//int image1[10]={8,6,1,9,2,0,5,7,4,3};
int n=262144;
int maxy1=0;
for (int x=0; x<n; x++)
{
printf("setting image[%d]=%d\n",x,x%10);
image[x]=x%10;
}
for (int x=0; x<n; x++)
{
printf("x iteration %d\n",x);
for (int y=0; y<n-1; y++)
{
if (y+1>maxy1)
maxy1=y+1;
if (image[y]>image[y+1])
{
int temp = image[y+1];
image[y+1] = image[y];
image[y] = temp;
}
}
}
printf("maxy1=%d\n",maxy1);
for (int x=0; x<50; x++)
{
printf("%d ",image[x]);
}
printf("\n");
}
|