Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. for(System::Int32 l=0; l<Convert::ToInt32(numericUpDown1->Value);l++)
  2. {
  3. //losowanie piksela oraz zmiany
  4. x=l_los->Next(0,rozmiar);
  5. y=l_los->Next(0,rozmiar);
  6. z=l_los->Next(0,8);
  7. // obliczanie energii
  8. for(System::Int32 i=-1; i<2;i++)
  9. {
  10. for(System::Int32 j=-1; j<2;j++)
  11. {
  12. if((x+i>=0)&&(x+i<rozmiar)&&(y+j>=0)&&(y+j<rozmiar))
  13. {
  14. suma1=+(System::Math::Pow(obraz2[i+x,j+y]-obraz2[x,y],2));
  15. suma2=+(System::Math::Pow(obraz2[i+x,j+y]-obraz1[i+x,j+y],2));
  16. }
  17. }
  18. }
  19. energia1=(beta*suma1)+(1/(2*System::Math::Pow(sigma,2))*suma2);
  20. suma1 = 0;
  21. suma2 = 0;
  22. // obliczanie energii dla zmiany
  23. pom1=obraz2[x,y];
  24. obraz2[x,y]=z;
  25. for(System::Int32 i=-1; i<2;i++)
  26. {
  27. for(System::Int32 j=-1; j<2;j++)
  28. {
  29. if((x+i>=0)&&(x+i<rozmiar)&&(y+j>=0)&&(y+j<rozmiar))
  30. {
  31. suma1=+(System::Math::Pow(obraz2[i+x,j+y]-obraz2[x,y],2));
  32. suma2=+(System::Math::Pow(obraz2[i+x,j+y]-obraz1[i+x,j+y],2));
  33. }
  34. }
  35. }
  36. energia2=(beta*suma1)+(1/(2*System::Math::Pow(sigma,2))*suma2);
  37. suma1 = 0;
  38. suma2 = 0;
  39. // sprawdzenie który wynik jest lepszy
  40. if (energia2>=energia1)
  41. {
  42. obraz2[x,y]=pom1;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement