tychoBCGEN  0.5
 All Data Structures Namespaces Files Functions Variables
color_segmentation.cpp
Go to the documentation of this file.
1 
6 #include "myscene.h"
7 #include "mainwindow.h"
8 #include "ui_mainwindow.h"
9 #include "global.h"
10 #include "image_stack.h"
11 #include <QPixmap>
12 #include <QString>
13 #include <QGraphicsScene>
14 #include <QPainter>
15 #include <QColor>
16 #include <QRgb>
17 #include <math.h>
18 
23 
24  if (no_image == false){
25 
27 
28  for (int i = 0; i < image.width(); i++){
29  for (int j = 0; j < image.height(); j++){
30 
31  if ((qRed(image_stack::imagestack.at(0).pixel(i,j)) >= pick_red - red_low)&&(qRed(image_stack::imagestack.at(0).pixel(i,j)) <= pick_red + red_up)
32  &&(qGreen(image_stack::imagestack.at(0).pixel(i,j)) >= pick_green - green_low)&&(qGreen(image_stack::imagestack.at(0).pixel(i,j)) <= pick_green + green_up)
33  &&(qBlue(image_stack::imagestack.at(0).pixel(i,j)) >= pick_blue - blue_low)&&(qBlue(image_stack::imagestack.at(0).pixel(i,j)) <= pick_blue + blue_up)){
34 
35  image.setPixel(i,j,final_mark_color.rgba());
36  }
37  }
38  }
39 
41 
43 
44  scene->clear();
45  pixmap = QPixmap::fromImage(image_stack::imagestack.last());
46  scene->addPixmap(pixmap);
47  ui->graphicsView->setScene(scene);
48  ui->graphicsView->setDragMode(ui->graphicsView->ScrollHandDrag);
49  ui->graphicsView->setFocus();
50  }
51 }
52 
57 
59 
60  scene->clear();
61  pixmap = QPixmap::fromImage(image);
62  scene->addPixmap(pixmap);
63  ui->graphicsView->setScene(scene);
64  ui->graphicsView->setDragMode(ui->graphicsView->ScrollHandDrag);
65  ui->graphicsView->setFocus();
66 
67  //now we can enable mask inverter
68  ui->invertmask->setEnabled(true);
69 
70  counter++;
71 
72 }
73 
78 
79  if (image_stack::imagestack.size() > 1){
82  image_stack::imagestack.pop_back();
83  scene->clear();
84  pixmap = QPixmap::fromImage(image);
85  scene->addPixmap(pixmap);
86  ui->graphicsView->setScene(scene);
87  ui->graphicsView->setDragMode(ui->graphicsView->ScrollHandDrag);
88  ui->graphicsView->setFocus();
89  }
90 }
91 
96 
97  if (no_image == false){
98  QColor tmp;
99  tmp = image_stack::imagestack.at(0).pixel(point.toPoint());
100  image.setPixel(point.toPoint(), tmp.rgba());
101 
102  scene->clear();
103  pixmap = QPixmap::fromImage(image);
104  scene->addPixmap(pixmap);
105  ui->graphicsView->setScene(scene);
106  ui->graphicsView->setDragMode(ui->graphicsView->ScrollHandDrag);
107  ui->graphicsView->setFocus();
108  }
109 }
114 
115  int boundarypixel[6];
116  QImage image_tmp_clear;
117  QColor special_color_for_marking;
118  bool stop;
119  bool stop_inner_while;
120  bool on;
121  int i;
122  int n;
123  int x;
124  int y;
125  int k;
126  int start_x;
127  int start_y;
128  int zero_decision;
129  int row_counter;
130  int break_condition;
131 
132  stop = false;
133  stop_inner_while = false;
134  on = false;
135  i = 0;
136  n = 0;
137  x = 0;
138  y = 0;
139  k = 0;
140  start_x = 1;
141  start_y = 0;
142  zero_decision = 0;
143  row_counter = 0;
144  break_condition = 0;
145 
146  for (n = 0; n < 6; n++) boundarypixel[n] = 0;
147 
148  special_color_for_marking.setAlpha(alpha_special_marking);
149  image_tmp_clear = image;
150 
151  if ((point.toPoint().x() >= 0)&&(point.toPoint().x()<image.width())
152  &&(point.toPoint().y() >= 0)
153  &&(point.toPoint().y()<image.height())
154  && (qAlpha(image.pixel(point.toPoint().x(),point.toPoint().y()))) == alpha){
155 
156  while (stop == false){
157  //first we go out of the whole in the mask
158  if (qAlpha(image.pixel(point.toPoint().x() + i, point.toPoint().y())) == alpha) {
159  if (point.toPoint().x() + i < image.width() - 1){
160  i++;
161  }
162  else{
163  //This is no island in the mask, we stop this procedure here
164  stop = true;
165  break;
166  }
167  }
168  else
169  {
170  //The first pixel in the boundary is found.
171  //If boundary is not a mask point the vluse 1 in the vector at the highlighted place
172  //| |2| |
173  //|1|x|3|
174  //| |4| |
175  //1 - boundarypixel[2]
176  //2 - boundarypixel[3]
177  //3 - boundarypixel[4]
178  //4 - boundarypixel[5]
179 
180  x = point.toPoint().x() + i;
181  y = point.toPoint().y();
182 
183  start_x = x;
184  start_y = y;
185 
186  //now lets walk counter-clockwise in the domain along the boundary
187  while (stop_inner_while == false){
188 
189  if (qAlpha(image.pixel(x - 1, y + 0)) == alpha){
190  boundarypixel[2] = 1;
191  }
192  else{
193  boundarypixel[2] = 0;
194  }
195  if (qAlpha(image.pixel(x + 0, y + 1)) == alpha){
196  boundarypixel[3] = 1;
197  }
198  else{
199  boundarypixel[3] = 0;
200  }
201  if (qAlpha(image.pixel(x + 1, y - 0)) == alpha){
202  boundarypixel[4] = 1;
203  }
204  else{
205  boundarypixel[4] = 0;
206  }
207  if (qAlpha(image.pixel(x + 0, y - 1)) == alpha){
208  boundarypixel[5] = 1;
209  }
210  else{
211  boundarypixel[5] = 0;
212  }
213  //now lets decide the next point
214  if ((boundarypixel[2] == 0)&&(boundarypixel[3] == 0)&&(boundarypixel[4] == 0)&&(boundarypixel[5] == 0)){
215  if (zero_decision == 2) x--;
216  if (zero_decision == 3) y++;
217  if (zero_decision == 4) x++;
218  if (zero_decision == 5) y--;
219  if (zero_decision == 6) x--;
220  if (zero_decision == 7) x--;
221  if (zero_decision == 8) y--;
222  if (zero_decision == 9) y++;
223  if (zero_decision == 10) y++;
224  if (zero_decision == 11) x++;
225  if (zero_decision == 12) x--;
226  if (zero_decision == 13) y--;
227  if (zero_decision == 14) x++;
228  if (zero_decision == 15) y++;
229 
230  }
231  if ((boundarypixel[2] == 1)&&(boundarypixel[3] == 0)&&(boundarypixel[4] == 0)&&(boundarypixel[5] == 0)){
232  y--;
233  zero_decision = 2;
234  }
235  if ((boundarypixel[2] == 0)&&(boundarypixel[3] == 1)&&(boundarypixel[4] == 0)&&(boundarypixel[5] == 0)){
236  x--;
237  zero_decision = 3;
238  }
239  if ((boundarypixel[2] == 0)&&(boundarypixel[3] == 0)&&(boundarypixel[4] == 1)&&(boundarypixel[5] == 0)){
240  y++;
241  zero_decision = 4;
242  }
243  if ((boundarypixel[2] == 0)&&(boundarypixel[3] == 0)&&(boundarypixel[4] == 0)&&(boundarypixel[5] == 1)){
244  x++;
245  zero_decision = 5;
246  }
247  if ((boundarypixel[2] == 1)&&(boundarypixel[3] == 1)&&(boundarypixel[4] == 0)&&(boundarypixel[5] == 0)){
248  y--;
249  zero_decision = 6;
250  }
251  if ((boundarypixel[2] == 1)&&(boundarypixel[3] == 0)&&(boundarypixel[4] == 1)&&(boundarypixel[5] == 0)){
252  y--;
253  zero_decision = 7;
254  }
255  if ((boundarypixel[2] == 1)&&(boundarypixel[3] == 0)&&(boundarypixel[4] == 0)&&(boundarypixel[5] == 1)){
256  x++;
257  zero_decision = 8;
258  }
259  if ((boundarypixel[2] == 0)&&(boundarypixel[3] == 1)&&(boundarypixel[4] == 1)&&(boundarypixel[5] == 0)){
260  x--;
261  zero_decision = 9;
262  }
263  if ((boundarypixel[2] == 0)&&(boundarypixel[3] == 1)&&(boundarypixel[4] == 0)&&(boundarypixel[5] == 1)){
264  x--;
265  zero_decision = 10;
266  }
267  if ((boundarypixel[2] == 0)&&(boundarypixel[3] == 0)&&(boundarypixel[4] == 1)&&(boundarypixel[5] == 1)){
268  y++;
269  zero_decision = 11;
270  }
271  if ((boundarypixel[2] == 1)&&(boundarypixel[3] == 1)&&(boundarypixel[4] == 1)&&(boundarypixel[5] == 0)){
272  y--;
273  zero_decision = 12;
274  }
275  if ((boundarypixel[2] == 1)&&(boundarypixel[3] == 1)&&(boundarypixel[4] == 0)&&(boundarypixel[5] == 1)){
276  x++;
277  zero_decision = 13;
278  }
279  if ((boundarypixel[2] == 1)&&(boundarypixel[3] == 0)&&(boundarypixel[4] == 1)&&(boundarypixel[5] == 1)){
280  y++;
281  zero_decision = 14;
282  }
283  if ((boundarypixel[2] == 0)&&(boundarypixel[3] == 1)&&(boundarypixel[4] == 1)&&(boundarypixel[5] == 1)){
284  x--;
285  zero_decision = 15;
286  }
287 
288  for (n = 0; n < 6; n++) boundarypixel[n] = 0;
289 
290  if ((x<0)||(y>image.width())) break;
291 
292  break_condition++;
293 
294  image_tmp_clear.setPixel(x,y,special_color_for_marking.rgba());
295 
296  if (break_condition == image.width()*image.height()) stop_inner_while = true;
297  if ((x == start_x)&&(y == start_y)) stop_inner_while = true;
298 
299  }
300  stop = true;
301  }
302  }
303  }
304 
305 
306  if ((x == start_x)&&(y == start_y)){
307  //Now we make a first check through the image to search for the numbers of the special_mark_color in a row
308  //for a further changes
309  for (n = 0; n < image.height(); n++){
310 
311  for (k = 0; k < image.width(); k++){
312  if (image_tmp_clear.pixel(k,n) == special_color_for_marking.rgba()){
313  row_counter++;
314  }
315 
316  }
317  //Now change the marking starting and stopping at the special_mark_color
318  on = false;
319 
320  if (row_counter > 1){
321  for (k = 0; k < image.width(); k++){
322 
323  if (image_tmp_clear.pixel(k,n) == special_color_for_marking.rgba()) row_counter--;
324 
325  if (image_tmp_clear.pixel(k,n) == special_color_for_marking.rgba()) on = false;
326 
327  if ((image_tmp_clear.pixel(k,n) == special_color_for_marking.rgba())&&
328  (image_tmp_clear.pixel(k+1,n) != special_color_for_marking.rgba()))
329  {
330  if (on == false){
331  on = true;
332  }
333  else{
334  on = false;
335  }
336  }
337  if (row_counter == 0) on = false;
338  if (on == true) image.setPixel(k+1,n,image_stack::imagestack.at(0).pixel(k+1,n));
339  }
340  }
341  //reset the row_counter
342  row_counter = 0;
343  }
344  }
345  else{
346 
347  //first get rid of artefacts of the more intelligent try
348  for (n = 0; n < image.height(); n++){
349  for (k = 0; k < image.width(); k++){
350  if (image_tmp_clear.pixel(k,n) == special_color_for_marking.rgba())
351  image.setPixel(k,n,image_stack::imagestack.at(0).pixel(k,n));
352  }
353  }
355  }
356 
358 
359  scene->clear();
360  pixmap = QPixmap::fromImage(image);
361  scene->addPixmap(pixmap);
362  ui->graphicsView->setScene(scene);
363  ui->graphicsView->setDragMode(ui->graphicsView->ScrollHandDrag);
364  ui->graphicsView->setFocus();
365 }
366 
371 
372  QColor tmp;
373 
374  int i;
375  int j;
376 
377  if (qAlpha(image.pixel(point.toPoint())) == alpha){
378 
379  for (j = 0; j < image.height() - point.toPoint().y(); j++){
380  i = 0;
381  if (qAlpha(image.pixel(point.toPoint().x() + i, point.toPoint().y() + j)) != alpha) break;
382  while (qAlpha(image.pixel(point.toPoint().x() + i, point.toPoint().y() + j)) == alpha){
383  tmp = image_stack::imagestack.at(0).pixel(point.toPoint().x() + i, point.toPoint().y() + j);
384  image.setPixel(point.toPoint().x() + i, point.toPoint().y() + j, tmp.rgba());
385  if (point.toPoint().x() + i < image.width() - 1){
386  i++;
387  }
388  else{
389  break;
390  }
391  }
392  }
393 
394  for (j = 0; j < image.height() - point.toPoint().y(); j++){
395  i = -1;
396  if (qAlpha(image.pixel(point.toPoint().x() + i, point.toPoint().y() + j)) != alpha) break;
397  while (qAlpha(image.pixel(point.toPoint().x() + i, point.toPoint().y() + j)) == alpha){
398  tmp = image_stack::imagestack.at(0).pixel(point.toPoint().x() + i, point.toPoint().y() + j);
399  image.setPixel(point.toPoint().x() + i, point.toPoint().y() + j, tmp.rgba());
400  if (point.toPoint().x() + i > - 1){
401  i--;
402  }
403  else{
404  break;
405  }
406  }
407  }
408 
409  for (j = 1; j < point.toPoint().y() + 1; j++){
410  i = 0;
411  if (qAlpha(image.pixel(point.toPoint().x() + i, point.toPoint().y() - j)) != alpha) break;
412  while (qAlpha(image.pixel(point.toPoint().x() + i, point.toPoint().y() - j)) == alpha){
413  tmp = image_stack::imagestack.at(0).pixel(point.toPoint().x() + i, point.toPoint().y() - j);
414  image.setPixel(point.toPoint().x() + i, point.toPoint().y() - j, tmp.rgba());
415  if (point.toPoint().x() + i < image.width()-1){
416  i++;
417  }
418  else{
419  break;
420  }
421  }
422  }
423 
424  for (j = 1; j < point.toPoint().y()+1; j++){
425  i = -1;
426  if (qAlpha(image.pixel(point.toPoint().x() + i, point.toPoint().y() - j)) != alpha) break;
427  while (qAlpha(image.pixel(point.toPoint().x() + i, point.toPoint().y() - j)) == alpha){
428  tmp = image_stack::imagestack.at(0).pixel(point.toPoint().x() + i, point.toPoint().y() - j);
429  image.setPixel(point.toPoint().x() + i, point.toPoint().y() - j, tmp.rgba());
430  if (point.toPoint().x() + i > 0){
431  i--;
432  }
433  else{
434  break;
435  }
436  }
437  }
438  }
439 
440 }
441 
446 
447  int boundarypixel[6];
448  QImage image_tmp_clear;
449  QColor special_color_for_marking;
450  bool stop;
451  bool stop_inner_while;
452  bool on;
453  int i;
454  int n;
455  int x;
456  int y;
457  int k;
458  int start_x;
459  int start_y;
460  int zero_decision;
461  int row_counter;
462  int break_condition;
463 
464  stop = false;
465  stop_inner_while = false;
466  on = false;
467  i = 0;
468  n = 0;
469  x = 0;
470  y = 0;
471  k = 0;
472  start_x = 1;
473  start_y = 0;
474  zero_decision = 0;
475  row_counter = 0;
476  break_condition = 0;
477 
478  for (n = 0; n < 6; n++) boundarypixel[n] = 0;
479 
480  special_color_for_marking.setAlpha(alpha_special_marking);
481  image_tmp_clear = image;
482 
483  if ((point.toPoint().x() >= 0)&&(point.toPoint().x()<image.width())
484  &&(point.toPoint().y() >= 0)
485  &&(point.toPoint().y()<image.height())
486  && (qAlpha(image.pixel(point.toPoint().x(),point.toPoint().y()))) != alpha){
487 
488  while (stop == false){
489  //first we go out of the whole in the mask
490  if (qAlpha(image.pixel(point.toPoint().x() + i, point.toPoint().y())) != alpha) {
491  if (point.toPoint().x() + i < image.width() - 1){
492  i++;
493  }
494  else{
495  //This is no island in the mask, we stop this procedure here
496  stop = true;
497  break;
498  }
499  }
500  else
501  {
502  //The first pixel in the boundary is found.
503  //If boundary is not a mask point the vluse 1 in the vector at the highlighted place
504  //| |2| |
505  //|1|x|3|
506  //| |4| |
507  //1 - boundarypixel[2]
508  //2 - boundarypixel[3]
509  //3 - boundarypixel[4]
510  //4 - boundarypixel[5]
511 
512  x = point.toPoint().x() + i;
513  y = point.toPoint().y();
514 
515  start_x = x;
516  start_y = y;
517 
518  //now lets walk counter-clockwise in the domain along the boundary
519  while (stop_inner_while == false){
520 
521  if (qAlpha(image.pixel(x - 1, y + 0)) != alpha){
522  boundarypixel[2] = 1;
523  }
524  else{
525  boundarypixel[2] = 0;
526  }
527  if (qAlpha(image.pixel(x + 0, y + 1)) != alpha){
528  boundarypixel[3] = 1;
529  }
530  else{
531  boundarypixel[3] = 0;
532  }
533  if (qAlpha(image.pixel(x + 1, y - 0)) != alpha){
534  boundarypixel[4] = 1;
535  }
536  else{
537  boundarypixel[4] = 0;
538  }
539  if (qAlpha(image.pixel(x + 0, y - 1)) != alpha){
540  boundarypixel[5] = 1;
541  }
542  else{
543  boundarypixel[5] = 0;
544  }
545  //now lets decide the next point
546  if ((boundarypixel[2] == 0)&&(boundarypixel[3] == 0)&&(boundarypixel[4] == 0)&&(boundarypixel[5] == 0)){
547  if (zero_decision == 2) x--;
548  if (zero_decision == 3) y++;
549  if (zero_decision == 4) x++;
550  if (zero_decision == 5) y--;
551  if (zero_decision == 6) x--;
552  if (zero_decision == 7) x--;
553  if (zero_decision == 8) y--;
554  if (zero_decision == 9) y++;
555  if (zero_decision == 10) y++;
556  if (zero_decision == 11) x++;
557  if (zero_decision == 12) x--;
558  if (zero_decision == 13) y--;
559  if (zero_decision == 14) x++;
560  if (zero_decision == 15) y++;
561 
562  }
563  if ((boundarypixel[2] == 1)&&(boundarypixel[3] == 0)&&(boundarypixel[4] == 0)&&(boundarypixel[5] == 0)){
564  y--;
565  zero_decision = 2;
566  }
567  if ((boundarypixel[2] == 0)&&(boundarypixel[3] == 1)&&(boundarypixel[4] == 0)&&(boundarypixel[5] == 0)){
568  x--;
569  zero_decision = 3;
570  }
571  if ((boundarypixel[2] == 0)&&(boundarypixel[3] == 0)&&(boundarypixel[4] == 1)&&(boundarypixel[5] == 0)){
572  y++;
573  zero_decision = 4;
574  }
575  if ((boundarypixel[2] == 0)&&(boundarypixel[3] == 0)&&(boundarypixel[4] == 0)&&(boundarypixel[5] == 1)){
576  x++;
577  zero_decision = 5;
578  }
579  if ((boundarypixel[2] == 1)&&(boundarypixel[3] == 1)&&(boundarypixel[4] == 0)&&(boundarypixel[5] == 0)){
580  y--;
581  zero_decision = 6;
582  }
583  if ((boundarypixel[2] == 1)&&(boundarypixel[3] == 0)&&(boundarypixel[4] == 1)&&(boundarypixel[5] == 0)){
584  y--;
585  zero_decision = 7;
586  }
587  if ((boundarypixel[2] == 1)&&(boundarypixel[3] == 0)&&(boundarypixel[4] == 0)&&(boundarypixel[5] == 1)){
588  x++;
589  zero_decision = 8;
590  }
591  if ((boundarypixel[2] == 0)&&(boundarypixel[3] == 1)&&(boundarypixel[4] == 1)&&(boundarypixel[5] == 0)){
592  x--;
593  zero_decision = 9;
594  }
595  if ((boundarypixel[2] == 0)&&(boundarypixel[3] == 1)&&(boundarypixel[4] == 0)&&(boundarypixel[5] == 1)){
596  x--;
597  zero_decision = 10;
598  }
599  if ((boundarypixel[2] == 0)&&(boundarypixel[3] == 0)&&(boundarypixel[4] == 1)&&(boundarypixel[5] == 1)){
600  y++;
601  zero_decision = 11;
602  }
603  if ((boundarypixel[2] == 1)&&(boundarypixel[3] == 1)&&(boundarypixel[4] == 1)&&(boundarypixel[5] == 0)){
604  y--;
605  zero_decision = 12;
606  }
607  if ((boundarypixel[2] == 1)&&(boundarypixel[3] == 1)&&(boundarypixel[4] == 0)&&(boundarypixel[5] == 1)){
608  x++;
609  zero_decision = 13;
610  }
611  if ((boundarypixel[2] == 1)&&(boundarypixel[3] == 0)&&(boundarypixel[4] == 1)&&(boundarypixel[5] == 1)){
612  y++;
613  zero_decision = 14;
614  }
615  if ((boundarypixel[2] == 0)&&(boundarypixel[3] == 1)&&(boundarypixel[4] == 1)&&(boundarypixel[5] == 1)){
616  x--;
617  zero_decision = 15;
618  }
619  if ((boundarypixel[2] == 1)&&(boundarypixel[3] == 1)&&(boundarypixel[4] == 1)&&(boundarypixel[5] == 1)){
620  break;
621  }
622 
623  for (n = 0; n < 6; n++) boundarypixel[n] = 0;
624 
625  if ((x<0)||(y>image.width())) break;
626 
627  break_condition++;
628 
629  image_tmp_clear.setPixel(x,y,special_color_for_marking.rgba());
630 
631  if (break_condition == image.width()*image.height()) stop_inner_while = true;
632  if ((x == start_x)&&(y == start_y)) stop_inner_while = true;
633 
634  }
635  stop = true;
636  }
637  }
638  }
639 
640 
641  if ((x == start_x)&&(y == start_y)){
642  //Now we make a first check through the image to search for the numbers of the special_mark_color in a row
643  //for a further changes
644  for (n = 0; n < image.height(); n++){
645 
646  for (k = 0; k < image.width(); k++){
647  if (image_tmp_clear.pixel(k,n) == special_color_for_marking.rgba()){
648  row_counter++;
649  }
650 
651  }
652  //Now change the marking starting and stopping at the special_mark_color
653  on = false;
654 
655  if (row_counter > 1){
656  for (k = 0; k < image.width(); k++){
657 
658  if (image_tmp_clear.pixel(k,n) == special_color_for_marking.rgba()) row_counter--;
659 
660  if (image_tmp_clear.pixel(k,n) == special_color_for_marking.rgba()) on = false;
661 
662  if ((image_tmp_clear.pixel(k,n) == special_color_for_marking.rgba())&&
663  (image_tmp_clear.pixel(k+1,n) != special_color_for_marking.rgba()))
664  {
665  if (on == false){
666  on = true;
667  }
668  else{
669  on = false;
670  }
671  }
672  if (row_counter == 0) on = false;
673  if (on == true) image.setPixel(k+1,n,final_mark_color.rgba());//image_stack::imagestack.at(0).pixel(k+1,n));
674  }
675  }
676  //reset the row_counter
677  row_counter = 0;
678  }
679  }
680  else{
681 
682  //first get rid of artefacts of the more intelligent try
683  for (n = 0; n < image.height(); n++){
684  for (k = 0; k < image.width(); k++){
685  if (image_tmp_clear.pixel(k,n) == special_color_for_marking.rgba())
686  image.setPixel(k,n,image_stack::imagestack.at(0).pixel(k,n));
687  }
688  }
689  mask_many_pixel();
690  }
691 
693 
694  scene->clear();
695  pixmap = QPixmap::fromImage(image);
696  scene->addPixmap(pixmap);
697  ui->graphicsView->setScene(scene);
698  ui->graphicsView->setDragMode(ui->graphicsView->ScrollHandDrag);
699  ui->graphicsView->setFocus();
700 }
701 
706 
707  int i;
708  int j;
709 
710  if ((point.toPoint().x() >= 0)&&(point.toPoint().x()<image.width())&&(point.toPoint().y() >= 0)
711  &&(point.toPoint().y()<image.height())){
712 
713  if (qAlpha(image.pixel(point.toPoint())) != alpha){
714 
715  for (j = 0; j < image.height() - point.toPoint().y(); j++){
716  i = 0;
717  if (qAlpha(image.pixel(point.toPoint().x() + i, point.toPoint().y() + j)) == alpha) break;
718  while (qAlpha(image.pixel(point.toPoint().x() + i, point.toPoint().y() + j)) != alpha){
719  image.setPixel(point.toPoint().x() + i, point.toPoint().y() + j, final_mark_color.rgba());
720  if (point.toPoint().x() + i < image.width()-1){
721  i++;
722  }
723  else{
724  break;
725  }
726  }
727  }
728 
729  for (j = 0; j < image.height() - point.toPoint().y(); j++){
730  i = -1;
731  if (qAlpha(image.pixel(point.toPoint().x() + i, point.toPoint().y() + j)) == alpha) break;
732  while (qAlpha(image.pixel(point.toPoint().x() + i, point.toPoint().y() + j)) != alpha){
733  image.setPixel(point.toPoint().x() + i, point.toPoint().y() + j, final_mark_color.rgba());
734  if (point.toPoint().x() + i > 0){
735  i--;
736  }
737  else{
738  break;
739  }
740  }
741  }
742 
743  for (j = 1; j < point.toPoint().y()+1; j++){
744  i = 0;
745  if (qAlpha(image.pixel(point.toPoint().x() + i, point.toPoint().y() - j)) == alpha) break;
746  while (qAlpha(image.pixel(point.toPoint().x() + i, point.toPoint().y() - j)) != alpha){
747  image.setPixel(point.toPoint().x() + i, point.toPoint().y() - j, final_mark_color.rgba());
748  if (point.toPoint().x() + i < image.width()-1){
749  i++;
750  }
751  else{
752  break;
753  }
754  }
755  }
756 
757  for (j = 1; j < point.toPoint().y()+1; j++){
758  i = -1;
759  if (qAlpha(image.pixel(point.toPoint().x() + i, point.toPoint().y() - j)) == alpha) break;
760  while (qAlpha(image.pixel(point.toPoint().x() + i, point.toPoint().y() - j)) != alpha){
761  image.setPixel(point.toPoint().x() + i, point.toPoint().y() - j, final_mark_color.rgba());
762  if (point.toPoint().x() + i > 0){
763  i--;
764  }
765  else{
766  break;
767  }
768  }
769  }
770  }
771  }
772 }
773 
778 
779  if (no_image == false){
780  image.setPixel(point.toPoint(), final_mark_color.rgba());
781 
782  scene->clear();
783  pixmap = QPixmap::fromImage(image);
784  scene->addPixmap(pixmap);
785  ui->graphicsView->setScene(scene);
786  ui->graphicsView->setDragMode(ui->graphicsView->ScrollHandDrag);
787  ui->graphicsView->setFocus();
788  }
789 }
790 
795 
796  for (int i = 0; i < image.width(); i++){
797  for (int j = 0; j < image.height(); j++){
798  if (image.pixel(i,j) == final_mark_color.rgba()){
799  image.setPixel(i,j,image_stack::imagestack.at(0).pixel(i,j));
800  }
801  else{
802  image.setPixel(i,j,final_mark_color.rgba());
803  }
804  }
805  }
806 
808 
810 
811  scene->clear();
812  pixmap = QPixmap::fromImage(image);
813  scene->addPixmap(pixmap);
814  ui->graphicsView->setScene(scene);
815  ui->graphicsView->setDragMode(ui->graphicsView->ScrollHandDrag);
816  ui->graphicsView->setFocus();
817 
818 
819 
820 }