public MatlabRunner(HttpServerUtility Server, HttpApplicationState Application) { m_server = Server; m_app = Application; m_matlab = new EngMATLib.EngMATAccess(); m_matlab.Evaluate("cd('" + m_server.MapPath("App_Data") + "');"); m_queue = new Queue <FmriRequest>(); m_doneList = new List <FmriRequest>(); m_newItemEvent = new AutoResetEvent(false); m_stopEvent = new ManualResetEvent(false); m_waitables = new WaitHandle[] { m_newItemEvent, m_stopEvent }; m_app["ReqHist"] = readFromHistory(); m_thread = new Thread(WorkLoop); m_thread.Start(); }
public MatlabRunner(HttpServerUtility Server, HttpApplicationState Application) { m_server = Server; m_app = Application; m_matlab = new EngMATLib.EngMATAccess(); m_matlab.Evaluate("cd('" + m_server.MapPath("App_Data") + "');"); m_queue = new Queue<FmriRequest>(); m_doneList = new List<FmriRequest>(); m_newItemEvent = new AutoResetEvent(false); m_stopEvent = new ManualResetEvent(false); m_waitables = new WaitHandle[] { m_newItemEvent, m_stopEvent }; m_app["ReqHist"] = readFromHistory(); m_thread = new Thread(WorkLoop); m_thread.Start(); }
public Image ApplyFourierInverse() { double[,] InvRed = new double[this.BitmapImage.Width, this.BitmapImage.Height]; double[,] InvGreen = new double[this.BitmapImage.Width, this.BitmapImage.Height]; double[,] InvBlue = new double[this.BitmapImage.Width, this.BitmapImage.Height]; Color[,] InvBuffer = new Color[this.BitmapImage.Width, this.BitmapImage.Height]; EngMATAccess engmat = new EngMATAccess(); engmat.SetMatrix("RedReal", RedReal); engmat.SetMatrix("GreenReal", GreenReal); engmat.SetMatrix("BlueReal", BlueReal); engmat.SetMatrix("RedImg", RedImg); engmat.SetMatrix("GreenImg", GreenImg); engmat.SetMatrix("BlueImg", BlueImg); engmat.Evaluate("InvRed=real(ifft2(ifftshift(RedReal+i*RedImg)));InvGreen=real(ifft2(ifftshift(GreenReal+i*GreenImg)));InvBlue=real(ifft2(ifftshift(BlueReal+i*BlueImg)));"); engmat.GetMatrix("InvRed", ref InvRed); engmat.GetMatrix("InvGreen", ref InvGreen); engmat.GetMatrix("InvBlue", ref InvBlue); BitmapImage = Normalize(InvRed, InvGreen, InvBlue, 0, 255); engmat.Close(); return this; }
public Image ApplyFourier() { double[,] Rr = new double[this.BitmapImage.Width, this.BitmapImage.Height]; double[,] Gg = new double[this.BitmapImage.Width, this.BitmapImage.Height]; double[,] Bb = new double[this.BitmapImage.Width, this.BitmapImage.Height]; RedReal = new double[this.BitmapImage.Width, this.BitmapImage.Height]; GreenReal = new double[this.BitmapImage.Width, this.BitmapImage.Height]; BlueReal = new double[this.BitmapImage.Width, this.BitmapImage.Height]; RedImg = new double[this.BitmapImage.Width, this.BitmapImage.Height]; GreenImg = new double[this.BitmapImage.Width, this.BitmapImage.Height]; BlueImg = new double[this.BitmapImage.Width, this.BitmapImage.Height]; for (int i = 0; i < this.BitmapImage.Height; i++) { for (int j = 0; j < this.BitmapImage.Width; j++) { Rr[j, i] = (double)this.BitmapImage.GetPixel(j, i).R; Gg[j, i] = (double)this.BitmapImage.GetPixel(j, i).G; Bb[j, i] = (double)this.BitmapImage.GetPixel(j, i).B; } } EngMATAccess engmat = new EngMATAccess(); engmat.SetMatrix("R", Rr); engmat.SetMatrix("G", Gg); engmat.SetMatrix("B", Bb); engmat.Evaluate("RedReal=real(fftshift(fft2(R)));GreenReal=real(fftshift(fft2(G)));BlueReal=real(fftshift(fft2(B)));"); engmat.GetMatrix("RedReal", ref RedReal); engmat.GetMatrix("GreenReal", ref GreenReal); engmat.GetMatrix("BlueReal", ref BlueReal); engmat.Evaluate("RedImg=imag(fftshift(fft2(R)));GreenImg=imag(fftshift(fft2(G)));BlueImg=imag(fftshift(fft2(B)));"); engmat.GetMatrix("RedImg", ref RedImg); engmat.GetMatrix("GreenImg", ref GreenImg); engmat.GetMatrix("BlueImg", ref BlueImg); Fourier = GetMagnitude() ; return this; }