2 using System.Collections.Generic;
5 using Microsoft.Xna.Framework;
6 using Microsoft.Xna.Framework.Content;
7 using Microsoft.Xna.Framework.Graphics;
8 using Microsoft.Xna.Framework.Input;
10 namespace visLU.Effects
18 GraphicsDevice device;
21 #region EffectParameters
24 private EffectParameter ep_rotationMatrix;
25 private EffectParameter ep_rgbTexture;
26 private EffectParameter ep_RGBtoXYZmatrix;
30 private EffectParameter ep_labTexture;
31 private EffectParameter ep_noiseTexture;
34 private EffectParameter ep_reductionTexture;
35 private EffectParameter ep_viewport;
38 private EffectParameter ep_pcaTexture;
41 private EffectParameter ep_eigenTexture;
45 private EffectParameter ep_projSumTexture;
46 private EffectParameter ep_projTexture;
50 private EffectParameter ep_resCTexture;
51 private EffectParameter ep_XYZtoRGBmatrix;
55 #region member variables
58 private Matrix rotation;
59 private Texture2D rgbtex;
60 private Matrix rgbToXYZ;
63 private Texture2D labTexture;
64 private Texture2D noiseTexture;
67 private Texture2D reductionTexture;
70 private Texture2D pcaTexture;
73 private Texture2D eigenTexture;
77 private Texture2D projSumTexture;
78 private Texture2D projTexture;
83 private Texture2D resultCTex;
84 private Matrix xyzToRGB;
91 public Matrix RotationMatrix
93 get {
return rotation; }
94 set { rotation = value; }
97 public Texture2D RGBTexture
99 get {
return rgbtex; }
100 set { rgbtex = value; }
103 public Matrix RGBtoXYZ
105 get {
return rgbToXYZ; }
106 set { rgbToXYZ = value; }
115 public Texture2D LabTexture
117 get {
return labTexture; }
118 set { labTexture = value; }
121 public Texture2D NoiseTexture
123 get {
return noiseTexture; }
124 set { noiseTexture = value; }
127 public Texture2D PCATexture
129 get {
return pcaTexture; }
130 set { pcaTexture = value; }
133 public Texture2D EigenTexture
135 get {
return eigenTexture; }
136 set { eigenTexture = value; }
139 public Texture2D EnhancedContrast_tex
141 get {
return resultCTex; }
142 set { resultCTex = value; }
156 Console.WriteLine(
"creating recolorshader");
167 ep_labTexture = this.Parameters[
"labTexture"];
168 ep_viewport = this.Parameters[
"viewport"];
177 rgbToXYZ =
new Matrix(0.6097559f, 0.2052401f, 0.1492240f, 0.0f,
178 0.3111242f, 0.6256560f, 0.0632197f, 0.0f,
179 0.0194811f, 0.0608902f, 0.7448387f, 0.0f,
180 0.0f, 0.0f, 0.0f, 1.0f);
224 ep_rotationMatrix = this.Parameters[
"rotmat"];
225 ep_viewport = this.Parameters[
"viewport"];
226 ep_rgbTexture = this.Parameters[
"RGBtexture"];
227 ep_RGBtoXYZmatrix = this.Parameters[
"mRGBtoXYZ"];
235 ep_labTexture = this.Parameters[
"labTexture"];
236 ep_noiseTexture = this.Parameters[
"noiseTexture"];
237 ep_viewport = this.Parameters[
"viewport"];
242 #region PredominantComponent
244 case "PredominantComponent":
245 ep_reductionTexture = this.Parameters[
"redTexture"];
246 ep_viewport = this.Parameters[
"viewport"];
254 ep_pcaTexture = this.Parameters[
"pcaTexture"];
262 ep_labTexture = this.Parameters[
"labTexture"];
263 ep_eigenTexture = this.Parameters[
"eigenTexture"];
268 #region MaxProjectionEffect
270 case "MaxProjectionEffect":
271 ep_reductionTexture = this.Parameters[
"redTexture"];
272 ep_viewport = this.Parameters[
"viewport"];
277 #region EnhanceContrast
279 case "EnhanceContrast":
280 ep_projSumTexture = this.Parameters[
"projEffectSumTexture"];
281 ep_projTexture = this.Parameters[
"projEffectTexture"];
282 ep_labTexture = this.Parameters[
"labTexture"];
283 ep_viewport = this.Parameters[
"viewport"];
293 xyzToRGB =
new Matrix(1.9624274f, -0.6105343f, -0.3413404f, 0.0f,
294 -0.9787684f, 1.9161415f, 0.0334540f, 0.0f,
295 0.0286869f, -0.1406752f, 1.3487655f, 0.0f,
296 0.0f, 0.0f, 0.0f, 1.0f);
320 ep_rotationMatrix = this.Parameters[
"rotmat"];
321 ep_viewport = this.Parameters[
"viewport"];
322 ep_resCTexture = this.Parameters[
"ResCtexture"];
323 ep_XYZtoRGBmatrix = this.Parameters[
"mXYZtoRGB"];
330 Console.WriteLine(
"RECOLORSHADER CREATED");
333 #region SetEffectParameter
336 public void SetEffectParameter_LMS(Texture2D _labTexture)
338 labTexture = _labTexture;
340 this.ep_labTexture.SetValue(_labTexture);
341 this.ep_viewport.SetValue(
new Vector2(GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height));
343 Console.WriteLine(
"effect parameters for lms shader set");
347 #region convert RGB to L*a*b*
348 public void SetEffectParameter_RGBtoLab()
353 this.ep_rotationMatrix.SetValue(rotation);
354 this.ep_viewport.SetValue(
new Vector2(GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height));
355 this.ep_rgbTexture.SetValue(rgbtex);
356 this.ep_RGBtoXYZmatrix.SetValue(rgbToXYZ);
358 Console.WriteLine(
"effect parameters for rgb to lab shader set");
363 public void SetEffectParameter_ContrastLoss(Texture2D _labTexture, Texture2D _noiseTexture)
365 labTexture = _labTexture;
366 noiseTexture = _noiseTexture;
368 this.ep_labTexture.SetValue(_labTexture);
369 this.ep_noiseTexture.SetValue(_noiseTexture);
370 this.ep_viewport.SetValue(
new Vector2(GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height));
373 public void SetEffectParameter_PCA1()
375 this.ep_labTexture.SetValue(labTexture);
376 this.ep_noiseTexture.SetValue(noiseTexture);
377 this.ep_viewport.SetValue(
new Vector2(GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height));
382 public void SetEffectParameter_PredominantComponenet(Texture2D _reductionTexture)
384 reductionTexture = _reductionTexture;
387 this.ep_reductionTexture.SetValue(reductionTexture);
389 this.ep_viewport.SetValue(
new Vector2(GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height));
394 public void SetEffectParameter_EigenVectors(Texture2D _pcaTexture)
396 pcaTexture = _pcaTexture;
397 this.ep_pcaTexture.SetValue(pcaTexture);
400 public void SetEffectParameter_EigenVec()
402 this.ep_pcaTexture.SetValue(pcaTexture);
406 #region Project onto LMS plane
407 public void SetEffectParameter_Projection(Texture2D _labTexture, Texture2D _eigenTexture)
409 labTexture = _labTexture;
410 eigenTexture = _eigenTexture;
412 this.ep_labTexture.SetValue(labTexture);
413 this.ep_eigenTexture.SetValue(eigenTexture);
418 public void SetEffectParameter_MaxProjectionEffect(Texture2D _reductionTexture)
420 reductionTexture = _reductionTexture;
423 this.ep_reductionTexture.SetValue(reductionTexture);
425 this.ep_viewport.SetValue(
new Vector2(GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height));
430 public void SetEffectParameter_EnhanceContrast(Texture2D _projSumImage, Texture2D _projectedImage, Texture2D _labImage)
432 projSumTexture = _projSumImage;
433 projTexture = _projectedImage;
434 labTexture = _labImage;
436 this.ep_projSumTexture.SetValue(projSumTexture);
437 this.ep_projTexture.SetValue(projTexture);
438 this.ep_labTexture.SetValue(labTexture);
439 this.ep_viewport.SetValue(
new Vector2(GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height));
443 #region convert L*a*b* back to RGB
444 internal void SetEffectParameter_labToRGB()
446 this.ep_rotationMatrix.SetValue(rotation);
447 this.ep_viewport.SetValue(
new Vector2(GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height));
448 this.ep_resCTexture.SetValue(resultCTex);
449 this.ep_XYZtoRGBmatrix.SetValue(xyzToRGB);
451 Console.WriteLine(
"effect parameters for lab to rgb shader set");