00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 #ifndef DEBUGWIN_H
00040 #define DEBUGWIN_H
00041
00042 #include "GUI/XWinManaged.H"
00043 #include "Image/Point2D.H"
00044 #include "Image/Pixels.H"
00045 #include "Image/Transforms.H"
00046 #include "Image/ColorOps.H"
00047 #include "Image/ShapeOps.H"
00048 #include "Image/MathOps.H"
00049 #include "Image/DrawOps.H"
00050 #include "Raster/Raster.H"
00051 #include "Image/CutPaste.H"
00052 #include "Envision/env_image.h"
00053
00054
00055 inline void SHOWIMG(Image<float> img, bool mag = false) {
00056 XWinManaged debug_xwin( img.getDims(), -1, -1, "DebugWin");
00057 Image<float> tmpImg = img;
00058 debug_xwin.drawImage(tmpImg);
00059 int key = -1;
00060 while(key != 24)
00061 {
00062 key = debug_xwin.getLastKeyPress();
00063 Point2D<int> p = debug_xwin.getLastMouseClick();
00064 if (p.isValid())
00065 {
00066 LINFO("Loc %ix%i pix value: %f", p.i, p.j, img.getVal(p));
00067
00068 if (mag)
00069 {
00070 Dims dims(9,9);
00071 int tl_i = p.i - dims.w()/2;
00072 int tl_j = p.j - dims.h()/2;
00073
00074 Image<float> c = crop(img, Point2D<int>(tl_i, tl_j), dims);
00075 SHOWIMG(rescaleNI(c, 256, 256));
00076 }
00077 }
00078
00079 if (key == 58)
00080 {
00081 Point2D<int> loc;
00082 float maxVal;
00083 findMax(img, loc, maxVal);
00084 LINFO("Max at %ix%i val=%f", loc.i, loc.j, maxVal);
00085
00086 drawDisk(img, loc, 6, 0.0F);
00087 drawCircle(tmpImg, loc, 6, maxVal);
00088 debug_xwin.drawImage(tmpImg);
00089 }
00090 usleep(10000);
00091 }
00092 }
00093
00094 inline void SHOWIMG(Image<byte> img, bool mag = false) {
00095 XWinManaged debug_xwin( img.getDims(), -1, -1, "DebugWin");
00096 debug_xwin.drawImage(img);
00097 int key = -1;
00098 while(key != 24)
00099 {
00100 key = debug_xwin.getLastKeyPress();
00101 Point2D<int> p = debug_xwin.getLastMouseClick();
00102 if (p.isValid())
00103 {
00104 LINFO("Loc %ix%i pix value: %i", p.i, p.j, img.getVal(p));
00105
00106 if (mag)
00107 {
00108 Dims dims(9,9);
00109 int tl_i = p.i - dims.w()/2;
00110 int tl_j = p.j - dims.h()/2;
00111
00112 Image<float> c = crop(img, Point2D<int>(tl_i, tl_j), dims);
00113 SHOWIMG(rescaleNI(c, 256, 256));
00114 }
00115
00116
00117 }
00118 usleep(10000);
00119 }
00120 }
00121
00122 inline void SHOWIMG(Image<PixRGB<byte> > img) {
00123
00124 if (img.initialized())
00125 {
00126 XWinManaged debug_xwin( img.getDims(), -1, -1, "DebugWin");
00127 debug_xwin.drawImage(img);
00128 int key = -1;
00129 while(key != 24)
00130 {
00131 key = debug_xwin.getLastKeyPress();
00132 Point2D<int> p = debug_xwin.getLastMouseClick();
00133 if (p.isValid())
00134 {
00135 PixRGB<byte> pix = img.getVal(p);
00136 LINFO("Loc %ix%i pix value: (%i,%i,%i)", p.i, p.j, pix[0], pix[1], pix[2]);
00137 }
00138 if (key == 25)
00139 Raster::WriteRGB(img, "DebugWin.ppm");
00140 usleep(10000);
00141 }
00142 }
00143 }
00144
00145 inline void ENV_SHOWIMG(struct env_image *img, int w=-1, int h=-1) {
00146
00147 if (w == -1 || h == -1)
00148 {
00149 w = img->dims.w;
00150 h = img->dims.h;
00151 }
00152
00153
00154 XWinManaged debug_xwin(Dims(w,h), -1, -1, "DebugWin");
00155
00156 Image<float> outImg(img->dims.w, img->dims.h, NO_INIT);
00157 const intg32* const src = img->pixels;
00158 const env_size_t sz = env_img_size(img);
00159 float* outImgPtr = outImg.getArrayPtr();
00160
00161 for (env_size_t i = 0; i < sz; ++i)
00162 outImgPtr[i] = (float) src[i];
00163
00164 outImg = rescale(outImg, w, h);
00165
00166 debug_xwin.drawImage(outImg);
00167 int key = -1;
00168 while(key != 24)
00169 {
00170 key = debug_xwin.getLastKeyPress();
00171 Point2D<int> p = debug_xwin.getLastMouseClick();
00172 if (p.isValid())
00173 {
00174 LINFO("Loc %ix%i pix value: %f", p.i, p.j, outImg.getVal(p));
00175 }
00176 usleep(10000);
00177 }
00178 }
00179
00180
00181
00182
00183 #endif