Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 751f74fd authored by Martin Genet's avatar Martin Genet
Browse files

Complete imaging models

parent a2952284
No related branches found
No related tags found
No related merge requests found
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
from builtins import * from builtins import *
import dolfin import dolfin
import glob
import math import math
import numpy import numpy
import os import os
......
...@@ -232,16 +232,6 @@ class Image(): ...@@ -232,16 +232,6 @@ class Image():
G[1] *= 0. G[1] *= 0.
G[2] *= math.copysign(1, math.sin(math.pi*X[2]/self.s)) * (math.pi/self.s) * math.cos(math.pi*X[2]/self.s) G[2] *= math.copysign(1, math.sin(math.pi*X[2]/self.s)) * (math.pi/self.s) * math.cos(math.pi*X[2]/self.s)
def I0_texture_tagging_XY_wDifferentiableCombination(self, X, I):
I[0] *= (1 + 3 * abs(math.sin(math.pi*X[0]/self.s))
* abs(math.sin(math.pi*X[1]/self.s)))**(1./2) - 1
def I0_texture_tagging_XY_wDifferentiableCombination_wGrad(self, X, I, G):
self.I0_texture_tagging_XY_wDifferentiableCombination(X, I)
G[0] *= 3 * math.copysign(1, math.sin(math.pi*X[0]/self.s)) * (math.pi/self.s) * math.cos(math.pi*X[0]/self.s) * abs(math.sin(math.pi*X[1]/self.s)) / 2 / (I[0] + 1)
G[1] *= 3 * math.copysign(1, math.sin(math.pi*X[1]/self.s)) * (math.pi/self.s) * math.cos(math.pi*X[1]/self.s) * abs(math.sin(math.pi*X[0]/self.s)) / 2 / (I[0] + 1)
G[2] *= 0.
def I0_texture_tagging_XY_wAdditiveCombination(self, X, I): def I0_texture_tagging_XY_wAdditiveCombination(self, X, I):
I[0] *= (abs(math.sin(math.pi*X[0]/self.s)) I[0] *= (abs(math.sin(math.pi*X[0]/self.s))
+ abs(math.sin(math.pi*X[1]/self.s)))/2 + abs(math.sin(math.pi*X[1]/self.s)))/2
...@@ -262,16 +252,26 @@ class Image(): ...@@ -262,16 +252,26 @@ class Image():
G[1] *= math.copysign(1, math.sin(math.pi*X[1]/self.s)) * (math.pi/self.s) * math.cos(math.pi*X[1]/self.s) * abs(math.sin(math.pi*X[0]/self.s)) / 2 / I[0] G[1] *= math.copysign(1, math.sin(math.pi*X[1]/self.s)) * (math.pi/self.s) * math.cos(math.pi*X[1]/self.s) * abs(math.sin(math.pi*X[0]/self.s)) / 2 / I[0]
G[2] *= 0. G[2] *= 0.
def I0_texture_tagging_XYZ_wDifferentiableCombination(self, X, I): def I0_texture_tagging_XY_wDifferentiableCombination(self, X, I):
I[0] *= (1 + 7 * abs(math.sin(math.pi*X[0]/self.s)) I[0] *= (1 + 3 * abs(math.sin(math.pi*X[0]/self.s))
* abs(math.sin(math.pi*X[1]/self.s)) * abs(math.sin(math.pi*X[1]/self.s)))**(1./2) - 1
* abs(math.sin(math.pi*X[2]/self.s)))**(1./3) - 1
def I0_texture_tagging_XYZ_wDifferentiableCombination_wGrad(self, X, I, G): def I0_texture_tagging_XY_wDifferentiableCombination_wGrad(self, X, I, G):
self.I0_texture_tagging_XYZ_wDifferentiableCombination(X, I) self.I0_texture_tagging_XY_wDifferentiableCombination(X, I)
G[0] *= 7 * math.copysign(1, math.sin(math.pi*X[0]/self.s)) * (math.pi/self.s) * math.cos(math.pi*X[0]/self.s) * abs(math.sin(math.pi*X[1]/self.s)) * abs(math.sin(math.pi*X[2]/self.s)) / 3 / (I[0] + 1) G[0] *= 3 * math.copysign(1, math.sin(math.pi*X[0]/self.s)) * (math.pi/self.s) * math.cos(math.pi*X[0]/self.s) * abs(math.sin(math.pi*X[1]/self.s)) / 2 / (I[0] + 1)
G[1] *= 7 * math.copysign(1, math.sin(math.pi*X[1]/self.s)) * (math.pi/self.s) * math.cos(math.pi*X[1]/self.s) * abs(math.sin(math.pi*X[0]/self.s)) * abs(math.sin(math.pi*X[2]/self.s)) / 3 / (I[0] + 1) G[1] *= 3 * math.copysign(1, math.sin(math.pi*X[1]/self.s)) * (math.pi/self.s) * math.cos(math.pi*X[1]/self.s) * abs(math.sin(math.pi*X[0]/self.s)) / 2 / (I[0] + 1)
G[2] *= 7 * math.copysign(1, math.sin(math.pi*X[2]/self.s)) * (math.pi/self.s) * math.cos(math.pi*X[2]/self.s) * abs(math.sin(math.pi*X[0]/self.s)) * abs(math.sin(math.pi*X[1]/self.s)) / 3 / (I[0] + 1) G[2] *= 0.
def I0_texture_tagging_XYZ_wAdditiveCombination(self, X, I):
I[0] *= (abs(math.sin(math.pi*X[0]/self.s))
+ abs(math.sin(math.pi*X[1]/self.s))
+ abs(math.sin(math.pi*X[2]/self.s)))/3
def I0_texture_tagging_XYZ_wAdditiveCombination_wGrad(self, X, I, G):
self.I0_texture_tagging_XYZ_wAdditiveCombination(X, I)
G[0] *= math.copysign(1, math.sin(math.pi*X[0]/self.s)) * (math.pi/self.s) * math.cos(math.pi*X[0]/self.s) / 3
G[1] *= math.copysign(1, math.sin(math.pi*X[1]/self.s)) * (math.pi/self.s) * math.cos(math.pi*X[1]/self.s) / 3
G[2] *= math.copysign(1, math.sin(math.pi*X[2]/self.s)) * (math.pi/self.s) * math.cos(math.pi*X[2]/self.s) / 3
def I0_texture_tagging_XYZ_wMultiplicativeCombination(self, X, I): def I0_texture_tagging_XYZ_wMultiplicativeCombination(self, X, I):
I[0] *= (abs(math.sin(math.pi*X[0]/self.s)) I[0] *= (abs(math.sin(math.pi*X[0]/self.s))
...@@ -284,6 +284,17 @@ class Image(): ...@@ -284,6 +284,17 @@ class Image():
G[1] *= math.copysign(1, math.sin(math.pi*X[1]/self.s)) * (math.pi/self.s) * math.cos(math.pi*X[1]/self.s) * abs(math.sin(math.pi*X[0]/self.s)) * abs(math.sin(math.pi*X[2]/self.s)) / 3 / I[0]**2 G[1] *= math.copysign(1, math.sin(math.pi*X[1]/self.s)) * (math.pi/self.s) * math.cos(math.pi*X[1]/self.s) * abs(math.sin(math.pi*X[0]/self.s)) * abs(math.sin(math.pi*X[2]/self.s)) / 3 / I[0]**2
G[2] *= math.copysign(1, math.sin(math.pi*X[2]/self.s)) * (math.pi/self.s) * math.cos(math.pi*X[2]/self.s) * abs(math.sin(math.pi*X[0]/self.s)) * abs(math.sin(math.pi*X[1]/self.s)) / 3 / I[0]**2 G[2] *= math.copysign(1, math.sin(math.pi*X[2]/self.s)) * (math.pi/self.s) * math.cos(math.pi*X[2]/self.s) * abs(math.sin(math.pi*X[0]/self.s)) * abs(math.sin(math.pi*X[1]/self.s)) / 3 / I[0]**2
def I0_texture_tagging_XYZ_wDifferentiableCombination(self, X, I):
I[0] *= (1 + 7 * abs(math.sin(math.pi*X[0]/self.s))
* abs(math.sin(math.pi*X[1]/self.s))
* abs(math.sin(math.pi*X[2]/self.s)))**(1./3) - 1
def I0_texture_tagging_XYZ_wDifferentiableCombination_wGrad(self, X, I, G):
self.I0_texture_tagging_XYZ_wDifferentiableCombination(X, I)
G[0] *= 7 * math.copysign(1, math.sin(math.pi*X[0]/self.s)) * (math.pi/self.s) * math.cos(math.pi*X[0]/self.s) * abs(math.sin(math.pi*X[1]/self.s)) * abs(math.sin(math.pi*X[2]/self.s)) / 3 / (I[0] + 1)
G[1] *= 7 * math.copysign(1, math.sin(math.pi*X[1]/self.s)) * (math.pi/self.s) * math.cos(math.pi*X[1]/self.s) * abs(math.sin(math.pi*X[0]/self.s)) * abs(math.sin(math.pi*X[2]/self.s)) / 3 / (I[0] + 1)
G[2] *= 7 * math.copysign(1, math.sin(math.pi*X[2]/self.s)) * (math.pi/self.s) * math.cos(math.pi*X[2]/self.s) * abs(math.sin(math.pi*X[0]/self.s)) * abs(math.sin(math.pi*X[1]/self.s)) / 3 / (I[0] + 1)
def I0_texture_tagging_signed_X(self, X, I): def I0_texture_tagging_signed_X(self, X, I):
I[0] *= (1+math.sin(math.pi*X[0]/self.s-math.pi/2))/2 I[0] *= (1+math.sin(math.pi*X[0]/self.s-math.pi/2))/2
...@@ -311,6 +322,26 @@ class Image(): ...@@ -311,6 +322,26 @@ class Image():
G[1] *= 0. G[1] *= 0.
G[2] *= (math.pi/self.s) * math.cos(math.pi*X[2]/self.s-math.pi/2) / 2 G[2] *= (math.pi/self.s) * math.cos(math.pi*X[2]/self.s-math.pi/2) / 2
def I0_texture_tagging_signed_XY_wAdditiveCombination(self, X, I):
I[0] *= ((1+math.sin(math.pi*X[0]/self.s-math.pi/2))/2
+ (1+math.sin(math.pi*X[1]/self.s-math.pi/2))/2) / 2
def I0_texture_tagging_signed_XY_wAdditiveCombination_wGrad(self, X, I, G):
self.I0_texture_tagging_signed_XY_wAdditiveCombination(X, I)
G[0] *= (math.pi/self.s) * math.cos(math.pi*X[0]/self.s-math.pi/2)/2 / 2
G[1] *= (math.pi/self.s) * math.cos(math.pi*X[1]/self.s-math.pi/2)/2 / 2
G[2] *= 0.
def I0_texture_tagging_signed_XY_wMultiplicativeCombination(self, X, I):
I[0] *= ((1+math.sin(math.pi*X[0]/self.s-math.pi/2))/2
* (1+math.sin(math.pi*X[1]/self.s-math.pi/2))/2)**(1./2)
def I0_texture_tagging_signed_XY_wMultiplicativeCombination_wGrad(self, X, I, G):
self.I0_texture_tagging_XY_wMultiplicativeCombination(X, I)
G[0] *= (math.pi/self.s) * math.cos(math.pi*X[0]/self.s-math.pi/2)/2 / 2 / I[0]
G[1] *= (math.pi/self.s) * math.cos(math.pi*X[1]/self.s-math.pi/2)/2 / 2 / I[0]
G[2] *= 0.
def I0_texture_tagging_signed_XY_wDifferentiableCombination(self, X, I): def I0_texture_tagging_signed_XY_wDifferentiableCombination(self, X, I):
I[0] *= (1 + 3 * (1+math.sin(math.pi*X[0]/self.s-math.pi/2))/2 I[0] *= (1 + 3 * (1+math.sin(math.pi*X[0]/self.s-math.pi/2))/2
* (1+math.sin(math.pi*X[1]/self.s-math.pi/2))/2)**(1./2) - 1 * (1+math.sin(math.pi*X[1]/self.s-math.pi/2))/2)**(1./2) - 1
...@@ -321,15 +352,27 @@ class Image(): ...@@ -321,15 +352,27 @@ class Image():
G[1] *= 3 * (math.pi/self.s) * math.cos(math.pi*X[1]/self.s-math.pi/2)/2 * (1+math.sin(math.pi*X[0]/self.s-math.pi/2))/2 / 2 / (I[0] + 1) G[1] *= 3 * (math.pi/self.s) * math.cos(math.pi*X[1]/self.s-math.pi/2)/2 * (1+math.sin(math.pi*X[0]/self.s-math.pi/2))/2 / 2 / (I[0] + 1)
G[2] *= 0. G[2] *= 0.
def I0_texture_tagging_signed_XY_wAdditiveCombination(self, X, I): def I0_texture_tagging_signed_XYZ_wAdditiveCombination(self, X, I):
I[0] *= ((1+math.sin(math.pi*X[0]/self.s-math.pi/2))/2 I[0] *= ((1+math.sin(math.pi*X[0]/self.s-math.pi/2))/2
+ (1+math.sin(math.pi*X[1]/self.s-math.pi/2))/2) / 2 + (1+math.sin(math.pi*X[1]/self.s-math.pi/2))/2
+ (1+math.sin(math.pi*X[2]/self.s-math.pi/2))/2) / 3
def I0_texture_tagging_signed_XY_wAdditiveCombination_wGrad(self, X, I, G): def I0_texture_tagging_signed_XYZ_wAdditiveCombination_wGrad(self, X, I, G):
self.I0_texture_tagging_signed_XY_wAdditiveCombination(X, I) self.I0_texture_tagging_signed_XYZ_wAdditiveCombination(X, I)
G[0] *= (math.pi/self.s) * math.cos(math.pi*X[0]/self.s-math.pi/2)/2 / 2 G[0] *= (math.pi/self.s) * math.cos(math.pi*X[0]/self.s-math.pi/2)/2 / 3
G[1] *= (math.pi/self.s) * math.cos(math.pi*X[1]/self.s-math.pi/2)/2 / 2 G[1] *= (math.pi/self.s) * math.cos(math.pi*X[1]/self.s-math.pi/2)/2 / 3
G[2] *= 0. G[2] *= (math.pi/self.s) * math.cos(math.pi*X[2]/self.s-math.pi/2)/2 / 3
def I0_texture_tagging_signed_XYZ_wMultiplicativeCombination(self, X, I):
I[0] *= ((1+math.sin(math.pi*X[0]/self.s-math.pi/2))/2
* (1+math.sin(math.pi*X[1]/self.s-math.pi/2))/2
* (1+math.sin(math.pi*X[2]/self.s-math.pi/2))/2)**(1./3)
def I0_texture_tagging_signed_XYZ_wMultiplicativeCombination_wGrad(self, X, I, G):
self.I0_texture_tagging_XYZ_wMultiplicativeCombination(X, I)
G[0] *= (math.pi/self.s) * math.cos(math.pi*X[0]/self.s-math.pi/2)/2 / 3 / I[0]
G[1] *= (math.pi/self.s) * math.cos(math.pi*X[1]/self.s-math.pi/2)/2 / 3 / I[0]
G[2] *= (math.pi/self.s) * math.cos(math.pi*X[2]/self.s-math.pi/2)/2 / 3 / I[0]
def I0_texture_tagging_signed_XYZ_wDifferentiableCombination(self, X, I): def I0_texture_tagging_signed_XYZ_wDifferentiableCombination(self, X, I):
I[0] *= (1 + 7 * (1+math.sin(math.pi*X[0]/self.s-math.pi/2))/2 I[0] *= (1 + 7 * (1+math.sin(math.pi*X[0]/self.s-math.pi/2))/2
...@@ -342,17 +385,6 @@ class Image(): ...@@ -342,17 +385,6 @@ class Image():
G[1] *= 7 * (math.pi/self.s) * math.cos(math.pi*X[1]/self.s-math.pi/2)/2 * (1+math.sin(math.pi*X[0]/self.s-math.pi/2))/2 * (1+math.sin(math.pi*X[2]/self.s-math.pi/2))/2 / 3 / (I[0] + 1) G[1] *= 7 * (math.pi/self.s) * math.cos(math.pi*X[1]/self.s-math.pi/2)/2 * (1+math.sin(math.pi*X[0]/self.s-math.pi/2))/2 * (1+math.sin(math.pi*X[2]/self.s-math.pi/2))/2 / 3 / (I[0] + 1)
G[2] *= 7 * (math.pi/self.s) * math.cos(math.pi*X[2]/self.s-math.pi/2)/2 * (1+math.sin(math.pi*X[0]/self.s-math.pi/2))/2 * (1+math.sin(math.pi*X[1]/self.s-math.pi/2))/2 / 3 / (I[0] + 1) G[2] *= 7 * (math.pi/self.s) * math.cos(math.pi*X[2]/self.s-math.pi/2)/2 * (1+math.sin(math.pi*X[0]/self.s-math.pi/2))/2 * (1+math.sin(math.pi*X[1]/self.s-math.pi/2))/2 / 3 / (I[0] + 1)
def I0_texture_tagging_signed_XYZ_wAdditiveCombination(self, X, I):
I[0] *= ((1+math.sin(math.pi*X[0]/self.s-math.pi/2))/2
+ (1+math.sin(math.pi*X[1]/self.s-math.pi/2))/2
+ (1+math.sin(math.pi*X[2]/self.s-math.pi/2))/2) / 3
def I0_texture_tagging_signed_XYZ_wAdditiveCombination_wGrad(self, X, I, G):
self.I0_texture_tagging_signed_XYZ_wAdditiveCombination(X, I)
G[0] *= (math.pi/self.s) * math.cos(math.pi*X[0]/self.s-math.pi/2)/2 / 3
G[1] *= (math.pi/self.s) * math.cos(math.pi*X[1]/self.s-math.pi/2)/2 / 3
G[2] *= (math.pi/self.s) * math.cos(math.pi*X[2]/self.s-math.pi/2)/2 / 3
def I0_noise_no(self, I): def I0_noise_no(self, I):
pass pass
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment