1 #include "HistoImageCanvas.hh"
3 #include <Gui/StringConv.hh>
5 #include <wx/dcbuffer.h>
13 wxStatusBar *sbar,
int sbarid,
19 : wxPanel(parent, id, pos, size, style, name)
21 SetMinSize(wxSize(294, 219));
68 OnMouseLeave(wxMouseEvent&)
70 if (SBar_){ SBar_->SetStatusText(wxT(
""), SBarID_); }
80 wxPoint pos =
event.GetPosition();
81 mousex_ = dc.DeviceToLogicalX( pos.x );
82 mousey_ = dc.DeviceToLogicalY( pos.y );
90 wxPoint pos = GetPosition();
92 int ix=(int)mouseX-(
int)pos.x;
93 int iy=(int)mouseY-(
int)pos.y;
95 wxSize sz = GetClientSize();
107 int cur_channel = (int)((iy-10)/slice);
110 if(
histo_type == 0 && cur_step>=0 && cur_step<256){
111 os <<
"UnsignedChar (Channel " << cur_channel
112 <<
") - Value " << cur_step
118 os <<
"Float (Channel " << cur_channel
139 BIASERR(
"No image for HISTOGRAMMS presented!");
142 if(histo_channels<=0 || histo_channels>=9){
143 cout <<
"Invalid amount of channels (allowed only 1, 2, 3, ..., 8 "
144 <<
"channels in the image" << endl;
154 std::vector<float> dummy_percentage;
168 std::vector<int> dummy;
171 dummy_percentage.clear();
172 for (
int j = 0; j < 256; j++){
174 dummy_percentage.push_back(0.0);
183 unsigned char* data = (
unsigned char*)image.
GetImageData();
212 for (
int j = 0; j < 256; j++){
239 std::vector<Histo_Entry_Float> dummy;
242 dummy_percentage.clear();
247 dummy.push_back(dummy_content);
248 dummy_percentage.push_back(0.0);
259 float min = 100000.0;
260 float max = -100000.0;
263 if((
float)data[i] > max){
264 max = (float)data[i];
269 if((
float)data[i] < min)
270 min = (
float)data[i];
273 if(min >= 100000.0 || max <= -100000.0)
274 BIASERR(
"Image has only pixels above 10^5 values or under -10^5");
290 index = (int)(((
float)data[j]-min)/step);
306 BIASERR(
"HISTOGRAMM IS WRONG, maybe TOO MANY STEPS/TOO WIDE RANGE");
321 index = (int)(((
float)data[j]-min)/step);
334 BIASERR(
"HISTOGRAMM IS WRONG, maybe TOO MANY STEPS/TOO WIDE RANGE");
349 float end = min + step;
354 if(begin <= 0.0 && end >= 0.0){
358 begin += step; end += step;
397 wxBufferedPaintDC dc(
this);
398 wxSize sz = GetClientSize();
404 dc.SetPen(*wxGREY_PEN);
405 dc.SetBrush(*wxGREY_BRUSH);
407 wxRect rectToDraw(0, 0, wid, hei);
409 dc.DrawRectangle(rectToDraw);
411 dc.SetPen(*wxWHITE_PEN);
412 dc.SetBrush(*wxWHITE_BRUSH);
422 else if(wid <= 768+16)
425 else if(wid <= 1024+16)
437 wxRect rectToDraw2(6, 6, 256*
histoZoom_+4, hei-12);
439 dc.DrawRectangle(rectToDraw2);
441 dc.SetPen(*wxLIGHT_GREY_PEN);
442 dc.SetBrush(*wxLIGHT_GREY_BRUSH);
448 wxRect rectToDraw3(8, hei-8-(2+slice)*i-slice,
450 dc.DrawRectangle(rectToDraw3);
455 dc.SetPen(*wxBLACK_PEN);
456 dc.SetBrush(*wxBLACK_BRUSH);
476 for(
int j = 0; j < end; j++){
477 h = (int)(((
float)slice)*
480 hei-h-8-(histo_channels-i-1)*(slice+2),
483 dc.DrawRectangle(rectToDraw);
491 wxSize sz = GetClientSize();
494 cout <<
"RESIZED-1 TO " << wid <<
", " << hei << endl << endl;
bool SameName(wxString name, bool settothenewone)
std::vector< std::vector< Histo_Entry_Float > > histo_float
void UpdateHistogramm(ImageBase image)
wxString AsciiToWx(const char *thestring)
Converts a C string to a wxString.
bool IsInterleaved() const
std::vector< std::vector< int > > histo_UC
It's a Canvas used to compute Histogram for current image working.
void UpdateStatusBar(unsigned mouseX, unsigned mouseY)
HistoImageCanvas(wxWindow *parent, wxStatusBar *sbar=NULL, int sbarid=0, wxWindowID id=-1, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(272, 216), long style=wxTAB_TRAVERSAL, const wxString &name=wxT("HistoImageCanvas"))
unsigned int GetWidth() const
void OnPaint(wxPaintEvent &event)
const void * GetImageData() const
unsigned int GetChannelCount() const
returns the number of Color channels, e.g.
unsigned int GetHeight() const
std::vector< float > histo_percentage_biggest
enum EStorageType GetStorageType() const
(8bit) unsigned char image storage type
void OnMouseMove(wxMouseEvent &event)
void NewImage(BIAS::ImageBase &im)
std::vector< std::vector< float > > histo_percentage
This is the base class for images in BIAS.
void OnResize(wxSizeEvent &event)