7 public class RGBSplitInfo
: IInfo
9 public override string Name
11 get { return Catalog.GetString("RGB Split"); }
14 public override string ShortName
19 public override string Author
21 get { return "Bartosz Taudul"; }
24 public override string Description
26 get { return Catalog.GetString("This plugin splits image to 3 color subchannels. (Red, Green, Blue)"); }
30 public class RGBSplitFactory
: IFactory
32 IInfo _info
= new RGBSplitInfo();
40 get { return IType.ImgProc; }
43 public void Initialize()
47 public Plugin
.Base
Create()
49 return new RGBSplitPlugin();
53 public class RGBSplitPlugin
: Plugin
.ImgProc
55 private float progress
;
57 public RGBSplitPlugin()
59 _info
= new RGBSplitInfo();
62 public override void Setup()
66 public override bool HasSetup
71 public override void Work()
75 ICommImage socket
= _in
[0] as ICommImage
;
76 IImage
[] img
= socket
.Images
;
78 IImage
[] res1
= new IImage
[img
.Length
];
79 IImage
[] res2
= new IImage
[img
.Length
];
80 IImage
[] res3
= new IImage
[img
.Length
];
82 for(int i
=0; i
<img
.Length
; i
++)
84 IImage
[] rgb
= Split(img
[i
]);
90 progress
= (float)i
/img
.Length
;
93 _out
= new CommSocket(3);
94 _out
[0] = new ICommImage(res1
, socket
.OriginalImages
, socket
.Categories
);
95 _out
[1] = new ICommImage(res2
, socket
.OriginalImages
, socket
.Categories
);
96 _out
[2] = new ICommImage(res3
, socket
.OriginalImages
, socket
.Categories
);
102 private IImage
[] Split(IImage img
)
104 byte[] r
= new byte[img
.H
* img
.W
];
105 byte[] g
= new byte[img
.H
* img
.W
];
106 byte[] b
= new byte[img
.H
* img
.W
];
108 if(img
.BPP
== BPP
.Grayscale
)
110 for(int y
=0; y
<img
.H
; y
++)
111 for(int x
=0; x
<img
.W
; x
++)
113 byte color
= (byte)img
[x
, y
];
114 r
[x
+ img
.W
*y
] = color
;
115 g
[x
+ img
.W
*y
] = color
;
116 b
[x
+ img
.W
*y
] = color
;
121 for(int y
=0; y
<img
.H
; y
++)
122 for(int x
=0; x
<img
.W
; x
++)
124 int color
= (int)img
[x
, y
];
125 r
[x
+ img
.W
*y
] = (byte)((color
& 0xFF0000) >> 16);
126 g
[x
+ img
.W
*y
] = (byte)((color
& 0x00FF00) >> 8);
127 b
[x
+ img
.W
*y
] = (byte)(color
& 0x0000FF);
131 IImage
[] ret
= new IImage
[3];
132 ret
[0] = new IImage(BPP
.Grayscale
, img
.W
, img
.H
, r
);
133 ret
[1] = new IImage(BPP
.Grayscale
, img
.W
, img
.H
, g
);
134 ret
[2] = new IImage(BPP
.Grayscale
, img
.W
, img
.H
, b
);
139 public override int NumIn { get { return 1; }
}
140 public override int NumOut { get { return 3; }
}
142 public override string DescIn(int n
)
144 return Catalog
.GetString("Input image.");
147 public override string DescOut(int n
)
150 return Catalog
.GetString("Red subchannel.");
152 return Catalog
.GetString("Green subchannel.");
154 return Catalog
.GetString("Blue subchannel.");
157 private static string[] matchin
= new string[] { "image/rgb" }
;
158 private static string[] matchout
= new string[] { "image/grayscale" }
;
160 public override string[] MatchIn { get { return matchin; }
}
161 public override string[] MatchOut { get { return matchout; }
}
163 public override float Progress { get { return progress; }
}