Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- for(System::Int32 l=0; l<Convert::ToInt32(numericUpDown1->Value);l++)
- {
- //losowanie piksela oraz zmiany
- x=l_los->Next(0,rozmiar);
- y=l_los->Next(0,rozmiar);
- z=l_los->Next(0,8);
- // obliczanie energii
- for(System::Int32 i=-1; i<2;i++)
- {
- for(System::Int32 j=-1; j<2;j++)
- {
- if((x+i>=0)&&(x+i<rozmiar)&&(y+j>=0)&&(y+j<rozmiar))
- {
- suma1=+(System::Math::Pow(obraz2[i+x,j+y]-obraz2[x,y],2));
- suma2=+(System::Math::Pow(obraz2[i+x,j+y]-obraz1[i+x,j+y],2));
- }
- }
- }
- energia1=(beta*suma1)+(1/(2*System::Math::Pow(sigma,2))*suma2);
- suma1 = 0;
- suma2 = 0;
- // obliczanie energii dla zmiany
- pom1=obraz2[x,y];
- obraz2[x,y]=z;
- for(System::Int32 i=-1; i<2;i++)
- {
- for(System::Int32 j=-1; j<2;j++)
- {
- if((x+i>=0)&&(x+i<rozmiar)&&(y+j>=0)&&(y+j<rozmiar))
- {
- suma1=+(System::Math::Pow(obraz2[i+x,j+y]-obraz2[x,y],2));
- suma2=+(System::Math::Pow(obraz2[i+x,j+y]-obraz1[i+x,j+y],2));
- }
- }
- }
- energia2=(beta*suma1)+(1/(2*System::Math::Pow(sigma,2))*suma2);
- suma1 = 0;
- suma2 = 0;
- // sprawdzenie który wynik jest lepszy
- if (energia2>=energia1)
- {
- obraz2[x,y]=pom1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement