-->
-->
Return list

# [recommend] Daniel help to see me this error diffusion algorithm is wrong? Question points: 200 points, knot tie man wangyaninglm]

Collection
 follow Wangyaninglm Wangyaninglm Version level: This version of expert points: 5164 Tie rate: 98.49% The landlord Published in: 01:01:35 2016-02-01 This algorithm is to allow the two value image to approximate the representation of gray images Code: there are OpenMP version, do not know where to go, and for advice ``` / / ERROR-diffusion.cpp: entrance point definition console application. / / Stdafx.h "#include" Omp.h "#include" Windows.h "#include" #include #include #include Comment #pragma (LIB, "opencv_core2410d.lib") Comment #pragma (LIB, "opencv_highgui2410d.lib") Comment #pragma (LIB, "opencv_imgproc2410d.lib") Namespace STD using; Namespace CV using; Error_diffusion void (int width unsigned, Int height unsigned, Short **InputImage unsigned, Short **OutputImage unsigned ) { For (int i unsigned = 0; I < i++; height-1) { For (int j unsigned = 0; J < j++; width) { / / calculate the output pixel value If (InputImage[i][j]<128) { OutputImage[i][j] = 0; } OutputImage[i][j] else{= 1;} / / errors Err int = 255*OutputImage[i][j] - InputImage[i][j]; / / error diffusion InputImage[i][j+1] = err * 7/16; InputImage[i+1][j-1] = err * 7/16; InputImage[i+1][j] = err * 7/16; InputImage[i+1][j+1] = err * 7/16; } } } Row int = 288; Col //int = width; Error_diffusion_omp void (int width unsigned, Int height unsigned, Short **InputImage unsigned, Short **OutputImage unsigned ) { Cpu_num int = //cpu (); omp_get_num_procs number   Col int = width; #pragma OMP parallel private (row, Col) / / parallel domain { Int = omp_get_num_threads (thread_id); / / each thread. Sleep (20*thread_id); / / according to the thread of short delay OMP for #pragma For (I int = 0; i< (height/cpu_num); i++) { Row = row*cpu_num + thread_id; For (Col = 0; col uchar (Y); For (x int = 0; x < x++; image_src.cols) { InputImage[y][x] = ptr[x]; OutputImage[y][x] = 0; } } Error_diffusion (image_src.cols, image_src.rows, InputImage, OutputImage); //error_diffusion_omp (image_src.cols, image_src.rows, InputImage, OutputImage); For (y int = 0; y < y++; image_src.rows) { *ptr= image_dst.ptr uchar (Y); For (x int = 0; x < x++; image_src.cols) { If (OutputImage[y][x]==1) { Ptr[x] = 255; } } } Imshow ("diffusion error", image_dst); WaitKey (0); Return 0; } ``` more Share to: /***Business text AD***/ /*body {margin:0; padding: 0;font:normal 12px simsun; }*/ .adtxt{text-align:center;} .adtxt ul{margin:5px 0;border-top:1px solid #B9B9B9;border-bottom:1px solid #B9B9B9;background-color:#F2F6FB;padding:5px 0;} .adtxt ul li{display: inline-block;font-size:12px;} .adtxt ul li a{color:#333;} /*a{color: #002D93;text-decoration:none;}*/ /*a:visited{color: #B00;text-decoration:none;}*/ /*a:hover{color: #B00; text-decoration: underline;}*/ Useful to me [0] Throw a brick [0] quote| report| Administration Reply times: 37
 follow Wangyaninglm Wangyaninglm Version level: This version of expert points: 5164 Tie rate: 98.49% #1 Score: 0 Reply to: 01:02:59 2016-02-01 Useful to me [0] Throw a brick [0] quote| report| Administration
 follow Wangyaninglm Wangyaninglm Version level: This version of expert points: 5164 Tie rate: 98.49% #2 Score: 0 Reply to: 01:07:23 2016-02-01 How to engage, indebted forever Useful to me [0] Throw a brick [0] quote| report| Administration
 follow Chenxin980 Chenxin980 Version level: This version of expert points: 0 Tie rate: 100% #3 Score: 0 Reply to: 08:20:53 2016-02-01 The reply to 09:28:05 2016-02-03 was deleted by the administrator Administration
 follow Mewiteor Mewiteor Version level: This version of expert points: 120 Tie rate: 0% #4 Score: 5 Reply to: 08:25:15 2016-02-01 Integer arithmetic to float a try Useful to me [0] Throw a brick [0] quote| report| Administration
 follow Mewiteor Mewiteor Version level: This version of expert points: 120 Tie rate: 0% #5 Score: 5 Reply to: 08:27:35 2016-02-01 In addition, at the time of the two layer for cycle, pay attention to the boundary conditions of J and I. Useful to me [0] Throw a brick [0] quote| report| Administration
 follow Jason_wentzel Jason_wentzel Version level: This version of expert points: 22678 Tie rate: 100% #6 Score: 5 Reply to: 08:34:51 2016-02-01 If you have not played. Useful to me [0] Throw a brick [0] quote| report| Administration
 follow Mewiteor Mewiteor Version level: This version of expert points: 120 Tie rate: 0% #7 Score: 15 Reply to: 08:37:09 2016-02-01 Also seems to be a symbol of the InputImage problem. Useful to me [0] Throw a brick [0] quote| report| Administration
 follow Trent1985 Trent1985 Version level: This version of expert points: 469 Tie rate: 93.33% #8 Score: 20 Reply to: 10:53:15 2016-02-01 A simple look, you are crossing the for cycle, this algorithm is to change it, right. Useful to me [0] Throw a brick [0] quote| report| Administration
 follow Zhao4zhong1 Zhao4zhong1 Version level: This version of expert points: 38345 Tie rate: 98.21% Michael In 2014 the total number of technical experts in the year ranked second Third In 2013 the total number of technical experts in the year ranked third Jinshi In 2012 the total number of technical experts in the year ranked seventh More Medal #9 Score: 100 Reply to: 11:08:51 2016-02-01 ```Comment #pragma (LIB, "gdiplus.lib") #include #include #include #include #include Namespace Gdiplus using; GetEncoderClsid int (WCHAR* format const, pClsid CLSID*) { UINT num = 0; / / number of image encoders UINT size = 0; / / size of the image encoder array in bytes PImageCodecInfo ImageCodecInfo* = NULL; GetImageEncodersSize (&num, &size); If return -1 (size = = 0); / / Failure PImageCodecInfo = (ImageCodecInfo*) (malloc (size)); If (pImageCodecInfo = = NULL) return -1; / / Failure GetImageEncoders (Num, size, pImageCodecInfo); For (J UINT = 0; J < ++j; Num) { If (wcscmp (pImageCodecInfo[j].MimeType, format) = = 0) { *pClsid = pImageCodecInfo[j].Clsid; Free (pImageCodecInfo); Return J; / / Success } } Free (pImageCodecInfo); Return -1; / / Failure } Error_diffusion void (int width unsigned, Int height unsigned, Short **InputImage unsigned, Short **OutputImage unsigned ) { For (int i unsigned = 0; I < i++; height-1) { For (int j unsigned = 1; J < j++; width-1) { / / calculate the output pixel value If (InputImage[i][j]<128) { OutputImage[i][j] = 0; } OutputImage[i][j] else{= 1;} / / errors Err InputImage[i][j] = (int) 255*OutputImage[i][j] - int; / / error diffusion Int v; InputImage[i (int)][j+1] v+=err*7/16; v=; if (v>255) v=255; if (v<0) v=0;][j+1]= V (short InputImage[i) unsigned; V= (int) InputImage[i+1][j-1]; v+=err*3/16; if (v>255) v=255; v=0 (v<0); InputImage[i+1][j-1]= (short unsigned) V (); (); () if; V= (int) InputImage[i+1][j; v+=err*5/16; v=255; if (v>255) if (v<0) v=0; InputImage[i+1][j]= (unsigned short V); V= (int) InputImage[i+1][j+1]; v+=err*1/16; if (v>255) v=255; v=0 (v<0); InputImage[i+1][j+1]= (short unsigned) V (); (); () if; } } } Main int () { Int j unsigned, y, x; Gdiplusstartupinput GdiplusStartupInput; Gdiplustoken ULONG_PTR; GdiplusStartup (&gdiplustoken, &gdiplusstartupinput, NULL); BMP Bitmap* = Bitmap new (gray.bmp "L"); Height UINT = bmp->GetHeight (); Width UINT = bmp->GetWidth (); Short **iImg= unsigned (short unsigned * *) malloc (height*sizeof (short unsigned *)) (); Assert (iImg); For (j=0; jGetPixel (x, y, &color); IImg[y][x]= (short unsigned) color.GetRed (); } } Error_diffusion (width, height, iImg, oImg); *clone Bitmap = bmp->Clone (0,0, width, height, PixelFormat24bppRGB); For (y=0; ySetPixel (x, y, color); } } EncoderClsid CLSID; GetEncoderClsid (image/bmp "L", &encoderClsid); Clone->Save (diffusion.bmp "L", &encoderClsid); Clone delete; For (j=0; j
 follow Wangyaninglm Wangyaninglm Version level: This version of expert points: 5164 Tie rate: 98.49% #10 Score: 0 Reply to: 11:07:52 2016-02-01 Reference 8 floor Trent1985 reply:A simple look, you are crossing the for cycle, this algorithm is to change it, right. I changed you is out of bounds, where bounds, I see the original algorithm is out of bounds. Useful to me [0] Throw a brick [0] quote| report| Administration
 follow Wangyaninglm Wangyaninglm Version level: This version of expert points: 5164 Tie rate: 98.49% #11 Score: 0 Reply to: 11:14:57 2016-02-01 Reference 9 floor zhao4zhong1 reply:```Comment #pragma (LIB, "gdiplus.lib") #include #include #include #include #include Namespace Gdiplus using; GetEncoderClsid int (WCHAR* format const, pClsid CLSID*) { UINT num = 0; / / number of image encoders UINT size = 0; / / size of the image encoder array in bytes PImageCodecInfo ImageCodecInfo* = NULL; GetImageEncodersSize (&num, &size); If return -1 (size = = 0); / / Failure PImageCodecInfo = (ImageCodecInfo*) (malloc (size)); If (pImageCodecInfo = = NULL) return -1; / / Failure GetImageEncoders (Num, size, pImageCodecInfo); For (J UINT = 0; J < ++j; Num) { If (wcscmp (pImageCodecInfo[j].MimeType, format) = = 0) { *pClsid = pImageCodecInfo[j].Clsid; Free (pImageCodecInfo); Return J; / / Success } } Free (pImageCodecInfo); Return -1; / / Failure } Error_diffusion void (int width unsigned, Int height unsigned, Short **InputImage unsigned, Short **OutputImage unsigned ) { For (int i unsigned = 0; I < i++; height-1) { For (int j unsigned = 1; J < j++; width-1) { / / calculate the output pixel value If (InputImage[i][j]<128) { OutputImage[i][j] = 0; } OutputImage[i][j] else{= 1;} / / errors Err InputImage[i][j] = (int) 255*OutputImage[i][j] - int; / / error diffusion Int v; InputImage[i (int)][j+1] v+=err*7/16; v=; if (v>255) v=255; if (v<0) v=0;][j+1]= V (short InputImage[i) unsigned; V= (int) InputImage[i+1][j-1]; v+=err*3/16; if (v>255) v=255; v=0 (v<0); InputImage[i+1][j-1]= (short unsigned) V (); (); () if; V= (int) InputImage[i+1][j; v+=err*5/16; v=255; if (v>255) if (v<0) v=0; InputImage[i+1][j]= (unsigned short V); V= (int) InputImage[i+1][j+1]; v+=err*1/16; if (v>255) v=255; v=0 (v<0); InputImage[i+1][j+1]= (short unsigned) V (); (); () if; } } } Main int () { Int j unsigned, y, x; Gdiplusstartupinput GdiplusStartupInput; Gdiplustoken ULONG_PTR; GdiplusStartup (&gdiplustoken, &gdiplusstartupinput, NULL); BMP Bitmap* = Bitmap new (gray.bmp "L"); Height UINT = bmp->GetHeight (); Width UINT = bmp->GetWidth (); Short **iImg= unsigned (short unsigned * *) malloc (height*sizeof (short unsigned *)) (); Assert (iImg); For (j=0; jGetPixel (x, y, &color); IImg[y][x]= (short unsigned) color.GetRed (); } } Error_diffusion (width, height, iImg, oImg); *clone Bitmap = bmp->Clone (0,0, width, height, PixelFormat24bppRGB); For (y=0; ySetPixel (x, y, color); } } EncoderClsid CLSID; GetEncoderClsid (image/bmp "L", &encoderClsid); Clone->Save (diffusion.bmp "L", &encoderClsid); Clone delete; For (j=0; j
 follow Zhao4zhong1 Zhao4zhong1 Version level: This version of expert points: 38345 Tie rate: 98.21% Michael In 2014 the total number of technical experts in the year ranked second Third In 2013 the total number of technical experts in the year ranked third Jinshi In 2012 the total number of technical experts in the year ranked seventh More Medal #12 Score: 10 Reply to: 11:19:12 2016-02-01 I told you that you are not impressed. Compare yourself to it. Reminder: the cow * s teacher can not replace the students to understand and to the toilet! Useful to me [0] Throw a brick [0] quote| report| Administration
 follow Mewiteor Mewiteor Version level: This version of expert points: 120 Tie rate: 0% #13 Score: 30 Reply to: 12:08:07 2016-02-01 Should be the main symbol of the InputImage problem The data type of InputImage[i][j] is short unsigned If 128<=InputImage[i][j]<255 Is a large number err==InputImage[i][j] - 255==65536- (a) InputImage[i][j]. The err spread to other pixels will enable other pixel becomes a great value greater than 128, making OutputImage[i][j] most is 255, so has a large white. Useful to me [0] Throw a brick [0] quote| report| Administration
 follow Mewiteor Mewiteor Version level: This version of expert points: 120 Tie rate: 0% #14 Score: 5 Reply to: 12:26:49 2016-02-01 Feel a little better with floating-point types, integer division is rounding operation errors, has been accumulated. Border refers to: j=0`InputImage[i+1][-1] = err * 7/16;` And you do not have the last line of pixels for the proliferation of errors, the last line of the last line:`InputImage[i][j+1] = err * 7/16;` Useful to me [0] Throw a brick [0] quote| report| Administration
 follow Mewiteor Mewiteor Version level: This version of expert points: 120 Tie rate: 0% #15 Score: 0 Reply to: 12:30:57 2016-02-01 There are bounds: j=width-1 ```InputImage[i][width] = err * 7/16; InputImage[i+1][width] = err * 7/16;``` Useful to me [0] Throw a brick [0] quote| report| Administration
 follow Qq_32131221 Qq_32131221 Version level: This version of expert points: 0 Tie rate: 100% #16 Score: 0 Reply to: 14:41:43 2016-02-01 You get points Useful to me [0] Throw a brick [0] quote| report| Administration
 follow Zhao4zhong1 Zhao4zhong1 Version level: This version of expert points: 38345 Tie rate: 98.21% Michael In 2014 the total number of technical experts in the year ranked second Third In 2013 the total number of technical experts in the year ranked third Jinshi In 2012 the total number of technical experts in the year ranked seventh More Medal #17 Score: 0 Reply to: 17:18:45 2016-02-01 Is the moderator recommended, you also don't see where the problem? Useful to me [0] Throw a brick [0] quote| report| Administration
 follow Zhao4zhong1 Zhao4zhong1 Version level: This version of expert points: 38345 Tie rate: 98.21% Michael In 2014 the total number of technical experts in the year ranked second Third In 2013 the total number of technical experts in the year ranked third Jinshi In 2012 the total number of technical experts in the year ranked seventh More Medal #18 Score: 0 Reply to: 17:24:23 2016-02-01 Only to find that it is recommended by the landlord. Estimate is the landlord also want to let the post of the people "I told you that you don't have a deep impression. Compare yourself to it. Reminder: the cow * s teacher can not replace the students to understand and to the toilet!" . Useful to me [0] Throw a brick [0] quote| report| Administration
 follow Who_is_xiaoming Who_is_xiaoming Version level: This version of expert points: 10 Tie rate: 100% #19 Score: 0 Reply to: 18:40:33 2016-02-01 If you Useful to me [0] Throw a brick [0] quote| report| Administration
 follow Qq973177663 Qq973177663 Version level: This version of expert points: 0 Tie rate: 0% #20 Score: 0 Reply to: 22:09:36 2016-02-01 Bangding Useful to me [0] Throw a brick [0] quote| report| Administration
 follow Wangyaninglm Wangyaninglm Version level: This version of expert points: 5164 Tie rate: 98.49% #21 Score: 0 Reply to: 23:07:01 2016-02-01 Reference 18 floor zhao4zhong1 reply:Only to find that it is recommended by the landlord. Estimate is the landlord also want to let the post of the people "I told you that you don't have a deep impression. Compare yourself to it. Reminder: the cow * s teacher can not replace the students to understand and to the toilet!" . Haha, Zhao teacher is too sharp, I recently looked at the OpenMP to optimize this, but also want to use OpenMP to write this down Useful to me [0] Throw a brick [0] quote| report| Administration
 follow Cattpon Cattpon Version level: This version of expert points: 142 Tie rate: 0% #22 Score: 0 Reply to: 00:02:15 2016-02-02 Reference 9 floor zhao4zhong1 reply:```Comment #pragma (LIB, "gdiplus.lib") #include #include #include #include #include Namespace Gdiplus using; GetEncoderClsid int (WCHAR* format const, pClsid CLSID*) { UINT num = 0; / / number of image encoders UINT size = 0; / / size of the image encoder array in bytes PImageCodecInfo ImageCodecInfo* = NULL; GetImageEncodersSize (&num, &size); If return -1 (size = = 0); / / Failure PImageCodecInfo = (ImageCodecInfo*) (malloc (size)); If (pImageCodecInfo = = NULL) return -1; / / Failure GetImageEncoders (Num, size, pImageCodecInfo); For (J UINT = 0; J < ++j; Num) { If (wcscmp (pImageCodecInfo[j].MimeType, format) = = 0) { *pClsid = pImageCodecInfo[j].Clsid; Free (pImageCodecInfo); Return J; / / Success } } Free (pImageCodecInfo); Return -1; / / Failure } Error_diffusion void (int width unsigned, Int height unsigned, Short **InputImage unsigned, Short **OutputImage unsigned ) { For (int i unsigned = 0; I < i++; height-1) { For (int j unsigned = 1; J < j++; width-1) { / / calculate the output pixel value If (InputImage[i][j]<128) { OutputImage[i][j] = 0; } OutputImage[i][j] else{= 1;} / / errors Err InputImage[i][j] = (int) 255*OutputImage[i][j] - int; / / error diffusion Int v; InputImage[i (int)][j+1] v+=err*7/16; v=; if (v>255) v=255; if (v<0) v=0;][j+1]= V (short InputImage[i) unsigned; V= (int) InputImage[i+1][j-1]; v+=err*3/16; if (v>255) v=255; v=0 (v<0); InputImage[i+1][j-1]= (short unsigned) V (); (); () if; V= (int) InputImage[i+1][j; v+=err*5/16; v=255; if (v>255) if (v<0) v=0; InputImage[i+1][j]= (unsigned short V); V= (int) InputImage[i+1][j+1]; v+=err*1/16; if (v>255) v=255; v=0 (v<0); InputImage[i+1][j+1]= (short unsigned) V (); (); () if; } } } Main int () { Int j unsigned, y, x; Gdiplusstartupinput GdiplusStartupInput; Gdiplustoken ULONG_PTR; GdiplusStartup (&gdiplustoken, &gdiplusstartupinput, NULL); BMP Bitmap* = Bitmap new (gray.bmp "L"); Height UINT = bmp->GetHeight (); Width UINT = bmp->GetWidth (); Short **iImg= unsigned (short unsigned * *) malloc (height*sizeof (short unsigned *)) (); Assert (iImg); For (j=0; jGetPixel (x, y, &color); IImg[y][x]= (short unsigned) color.GetRed (); } } Error_diffusion (width, height, iImg, oImg); *clone Bitmap = bmp->Clone (0,0, width, height, PixelFormat24bppRGB); For (y=0; ySetPixel (x, y, color); } } EncoderClsid CLSID; GetEncoderClsid (image/bmp "L", &encoderClsid); Clone->Save (diffusion.bmp "L", &encoderClsid); Clone delete; For (j=0; j
 follow Michaelxiao612 Michaelxiao612 Version level: This version of expert points: 1 Tie rate: 0% #23 Score: 1 Reply to: 02:57:46 2016-02-02 This is the diffusion halftone error algorithm, the basic principle of the printer. Our laboratory is a lot of people walking in the study of halftone algorithm Useful to me [0] Throw a brick [0] quote| report| Administration
 follow Chenxin980 Chenxin980 Version level: This version of expert points: 0 Tie rate: 100% #24 Score: 0 Reply to: 08:17:38 2016-02-02 The reply to 09:28:06 2016-02-03 was deleted by the administrator Administration
 follow Gefieder Gefieder Version level: This version of expert points: 66 Tie rate: 100% #25 Score: 1 Reply to: 09:40:42 2016-02-02 Learning Useful to me [0] Throw a brick [0] quote| report| Administration
 follow A2048687 A2048687 Version level: This version of expert points: 1 Tie rate: 0% #26 Score: 1 Reply to: 09:58:08 2016-02-02 Ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah Useful to me [0] Throw a brick [0] quote| report| Administration
 follow A1509259923 A1509259923 Version level: This version of expert points: 1 Tie rate: 0% #27 Score: 1 Reply to: 11:46:52 2016-02-02 Worship master ~ learning Useful to me [0] Throw a brick [0] quote| report| Administration
 follow Kacherylau Kacherylau Version level: This version of expert points: 1 Tie rate: 0% #28 Score: 1 Reply to: 17:05:49 2016-02-02 To be honest, I don't know why, but I still need to work hard.. Useful to me [0] Throw a brick [0] quote| report| Administration
 follow Wangyaninglm Wangyaninglm Version level: This version of expert points: 5164 Tie rate: 98.49% #29 Score: 0 Reply to: 21:34:11 2016-02-02 Reference 17 floor zhao4zhong1 reply:Is the moderator recommended, you also don't see where the problem? Master, can you help me to see how the OpenMP version of the rewrite Useful to me [0] Throw a brick [0] quote| report| Administration
 follow U013126437 U013126437 Version level: This version of expert points: 0 Tie rate: 0% #30 Score: 0 Reply to: 09:34:06 2016-02-03 Heavy words in all of the heavy heavy heavy in the heavily in many of his Useful to me [0] Throw a brick [0] quote| report| Administration
 follow Zhao4zhong1 Zhao4zhong1 Version level: This version of expert points: 38345 Tie rate: 98.21% Michael In 2014 the total number of technical experts in the year ranked second Third In 2013 the total number of technical experts in the year ranked third Jinshi In 2012 the total number of technical experts in the year ranked seventh More Medal #31 Score: 0 Reply to: 11:00:12 2016-02-03 Reference 29 floor wangyaninglm reply:Quote: reference 17 floor zhao4zhong1 reply: Is the moderator recommended, you also don't see where the problem? Master, can you help me to see how the OpenMP version of the rewrite I don't have a OpenMP, but I believe your ability to draw inferences or some. Useful to me [0] Throw a brick [0] quote| report| Administration
 follow Lm_whales Lm_whales Version level: This version of expert points: 2128 Tie rate: 0% Yellow April 2014 C/C++ large version of the experts in the month list second blue flower February 2016 C/C++ large version of the experts in the month list thirdJanuary 2016 C/C++ large version of the experts in the month list third #32 Score: 0 Reply to: 17:54:26 2016-02-04 Reference 9 floor zhao4zhong1 reply:```Comment #pragma (LIB, "gdiplus.lib") #include #include #include #include #include Namespace Gdiplus using; GetEncoderClsid int (WCHAR* format const, pClsid CLSID*) { UINT num = 0; / / number of image encoders UINT size = 0; / / size of the image encoder array in bytes PImageCodecInfo ImageCodecInfo* = NULL; GetImageEncodersSize (&num, &size); If return -1 (size = = 0); / / Failure PImageCodecInfo = (ImageCodecInfo*) (malloc (size)); If (pImageCodecInfo = = NULL) return -1; / / Failure GetImageEncoders (Num, size, pImageCodecInfo); For (J UINT = 0; J < ++j; Num) { If (wcscmp (pImageCodecInfo[j].MimeType, format) = = 0) { *pClsid = pImageCodecInfo[j].Clsid; Free (pImageCodecInfo); Return J; / / Success } } Free (pImageCodecInfo); Return -1; / / Failure } Error_diffusion void (int width unsigned, Int height unsigned, Short **InputImage unsigned, Short **OutputImage unsigned ) { For (int i unsigned = 0; I < i++; height-1) { For (int j unsigned = 1; J < j++; width-1) { / / calculate the output pixel value If (InputImage[i][j]<128) { OutputImage[i][j] = 0; } OutputImage[i][j] else{= 1;} / / errors Err InputImage[i][j] = (int) 255*OutputImage[i][j] - int; / / error diffusion Int v; InputImage[i (int)][j+1] v+=err*7/16; v=; if (v>255) v=255; if (v<0) v=0;][j+1]= V (short InputImage[i) unsigned; V= (int) InputImage[i+1][j-1]; v+=err*3/16; if (v>255) v=255; v=0 (v<0); InputImage[i+1][j-1]= (short unsigned) V (); (); () if; V= (int) InputImage[i+1][j; v+=err*5/16; v=255; if (v>255) if (v<0) v=0; InputImage[i+1][j]= (unsigned short V); V= (int) InputImage[i+1][j+1]; v+=err*1/16; if (v>255) v=255; v=0 (v<0); InputImage[i+1][j+1]= (short unsigned) V (); (); () if; } } } Main int () { Int j unsigned, y, x; Gdiplusstartupinput GdiplusStartupInput; Gdiplustoken ULONG_PTR; GdiplusStartup (&gdiplustoken, &gdiplusstartupinput, NULL); BMP Bitmap* = Bitmap new (gray.bmp "L"); Height UINT = bmp->GetHeight (); Width UINT = bmp->GetWidth (); Short **iImg= unsigned (short unsigned * *) malloc (height*sizeof (short unsigned *)) (); Assert (iImg); For (j=0; jGetPixel (x, y, &color); IImg[y][x]= (short unsigned) color.GetRed (); } } Error_diffusion (width, height, iImg, oImg); *clone Bitmap = bmp->Clone (0,0, width, height, PixelFormat24bppRGB); For (y=0; ySetPixel (x, y, color); } } EncoderClsid CLSID; GetEncoderClsid (image/bmp "L", &encoderClsid); Clone->Save (diffusion.bmp "L", &encoderClsid); Clone delete; For (j=0; j
 follow Wsyouhou Wsyouhou Version level: This version of expert points: 0 Tie rate: 0% #33 Score: 0 Reply to: 22:19:39 2016-02-14 Seems like a very complicated feeling Useful to me [0] Throw a brick [0] quote| report| Administration
 follow Smartbetter Smartbetter Version level: This version of expert points: 0 Tie rate: 0% #34 Score: 0 Reply to: 23:35:01 2016-02-15 Useful to me [0] Throw a brick [0] quote| report| Administration
 follow Brk1985 Brk1985 Version level: This version of expert points: 1012 Tie rate: 100% #35 Score: 0 Reply to: 09:32:27 2016-02-16 If you Useful to me [0] Throw a brick [0] quote| report| Administration
 follow Qlx787238211 Qlx787238211 Version level: This version of expert points: 0 Tie rate: 0% #36 Score: 0 Reply to: 15:08:53 2016-02-17 Useful to me [0] Throw a brick [0] quote| report| Administration
 follow Lgx062800 Lgx062800 Version level: This version of expert points: 0 Tie rate: 0% #37 Score: 0 Reply to: 00:59:10 2016-02-19 Reference 4 floor mewiteor reply:Integer arithmetic to float a try ????? Useful to me [0] Throw a brick [0] quote| report| Administration
Return list
Reply content   The mobile client replies expert points doubled, Download experience!
1. Please comply with CSDNUser behavior criterion, shall not violate the laws and regulations of the state.
2. Reproduced in the article, please indicate "CSDN (prog3.com)". For commercial purposes, please contact the original author.