{"id":4795,"date":"2020-03-24T16:03:50","date_gmt":"2020-03-24T07:03:50","guid":{"rendered":"http:\/\/aval-global.com\/?p=4795"},"modified":"2020-03-24T20:16:55","modified_gmt":"2020-03-24T11:16:55","slug":"c-comparison-of-obtaining-the-brightness-value-of-image","status":"publish","type":"post","link":"https:\/\/aval-global.com\/?p=4795","title":{"rendered":"[C#] Comparison processing time of obtaining the brightness value of image"},"content":{"rendered":"<p><div class=\"fusion-fullwidth fullwidth-box fusion-builder-row-1 fusion-flex-container nonhundred-percent-fullwidth non-hundred-percent-height-scrolling\" style=\"--awb-border-radius-top-left:0px;--awb-border-radius-top-right:0px;--awb-border-radius-bottom-right:0px;--awb-border-radius-bottom-left:0px;--awb-flex-wrap:wrap;\" ><div class=\"fusion-builder-row fusion-row fusion-flex-align-items-flex-start fusion-flex-content-wrap\" style=\"max-width:calc( 1150px + 0px );margin-left: calc(-0px \/ 2 );margin-right: calc(-0px \/ 2 );\"><div class=\"fusion-layout-column fusion_builder_column fusion-builder-column-0 fusion_builder_column_1_1 1_1 fusion-flex-column\" style=\"--awb-bg-size:cover;--awb-width-large:100%;--awb-margin-top-large:0px;--awb-spacing-right-large:0px;--awb-margin-bottom-large:0px;--awb-spacing-left-large:0px;--awb-width-medium:100%;--awb-spacing-right-medium:0px;--awb-spacing-left-medium:0px;--awb-width-small:100%;--awb-spacing-right-small:0px;--awb-spacing-left-small:0px;\"><div class=\"fusion-column-wrapper fusion-flex-justify-content-flex-start fusion-content-layout-column\"><div class=\"fusion-text fusion-text-1\"><p>It is common to obtain or set up the brightness by exposing the button at LockBits~UnlockBits in C#, as using GetPixel or SetPixel method make the brightness value obtaining process slow. Today, I will compare the processing time by using different modes.<\/p>\n<table style=\"border-collapse: collapse; width: 37.926%; height: 168px;\" border=\"1\">\n<tbody>\n<tr style=\"height: 24px;\">\n<td style=\"width: 10.6962%; background-color: #1940b5; height: 24px;\" colspan=\"2\"><span style=\"color: #ffffff;\">Testing Environment<\/span><\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 10.6962%; height: 24px;\">OS<\/td>\n<td style=\"width: 27.2603%; height: 24px;\">Windows10 64bit ver.1809<\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 10.6962%; height: 24px;\">CPU<\/td>\n<td style=\"width: 27.2603%; height: 24px;\">Intel Core i7-7700K 4.2GHz<\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 10.6962%; height: 24px;\">Memory<\/td>\n<td style=\"width: 27.2603%; height: 24px;\">32GB<\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 10.6962%; height: 24px;\">.NET Framework<\/td>\n<td style=\"width: 27.2603%; height: 24px;\">4.5.2<\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 10.6962%; height: 24px;\">Platform<\/td>\n<td style=\"width: 27.2603%; height: 24px;\">Any CPU (32Bit prioritized)<\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 10.6962%; height: 24px;\">Evaluation Image<\/td>\n<td style=\"width: 27.2603%; height: 24px;\">JPEG 6,000 x 4,000px 24bit Color<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>In this test, I will obtain the color image\u2019s brightness value in R,G,B respectively and use the program, in which I reverse the intensity value and re-apply the brightness value of the color image.<\/p>\n<ul>\n<li>I set up the process to repeat in the order of \u201cbright\u2192dark\u2192bright\u2192dark\u201d as seen below.<\/li>\n<li>Processing time : I measured the average time in processing 5 repetitions.<\/li>\n<\/ul>\n<p><img decoding=\"async\" class=\"alignnone size-800\" src=\"https:\/\/imagingsolution.net\/wordpress\/wp-content\/uploads\/2019\/11\/set_get_bright_speed_1.png\" width=\"391\" height=\"353\" \/><img decoding=\"async\" class=\"alignnone size-800\" src=\"https:\/\/imagingsolution.net\/wordpress\/wp-content\/uploads\/2019\/11\/set_get_bright_speed_2.png\" width=\"391\" height=\"353\" \/><\/p>\n<\/div><\/div><\/div><div class=\"fusion-layout-column fusion_builder_column fusion-builder-column-1 fusion_builder_column_1_1 1_1 fusion-flex-column\" style=\"--awb-bg-size:cover;--awb-width-large:100%;--awb-margin-top-large:0px;--awb-spacing-right-large:0px;--awb-margin-bottom-large:0px;--awb-spacing-left-large:0px;--awb-width-medium:100%;--awb-spacing-right-medium:0px;--awb-spacing-left-medium:0px;--awb-width-small:100%;--awb-spacing-right-small:0px;--awb-spacing-left-small:0px;\"><div class=\"fusion-column-wrapper fusion-flex-justify-content-flex-start fusion-content-layout-column\"><div class=\"fusion-text fusion-text-2\"><h3>1. Using GetPixel, SetPixel<\/h3>\n<\/div><style type=\"text\/css\" scopped=\"scopped\">.fusion-syntax-highlighter-1 > .CodeMirror, .fusion-syntax-highlighter-1 > .CodeMirror .CodeMirror-gutters {background-color:var(--awb-color1);}.fusion-syntax-highlighter-1 > .CodeMirror .CodeMirror-gutters { background-color: var(--awb-color2); }.fusion-syntax-highlighter-1 > .CodeMirror .CodeMirror-linenumber { color: var(--awb-color8); }<\/style><div class=\"fusion-syntax-highlighter-container fusion-syntax-highlighter-1 fusion-syntax-highlighter-theme-light\" style=\"opacity:0;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:14px;border-width:1px;border-style:solid;border-color:var(--awb-color3);\"><div class=\"syntax-highlighter-copy-code\"><span class=\"syntax-highlighter-copy-code-title\" data-id=\"fusion_syntax_highlighter_1\" style=\"font-size:14px;\">Copy to Clipboard<\/span><\/div><label for=\"fusion_syntax_highlighter_1\" class=\"screen-reader-text\">Syntax Highlighter<\/label><textarea class=\"fusion-syntax-highlighter-textarea\" id=\"fusion_syntax_highlighter_1\" data-readOnly=\"nocursor\" data-lineNumbers=\"1\" data-lineWrapping=\"\" data-theme=\"default\" data-mode=\"text\/x-scss\">\/\/\/ <summary>\n\/\/\/ Set up the brightness value with GetPixel\u3001SetPixel\n\/\/\/ <\/summary>\n\/\/\/ <param name=\"bmp\"><\/param>\nprivate void NegativeImage1(Bitmap bmp)\n{\nvar width = bmp.Width;\nvar height = bmp.Height;\nColor col;\nint r, g, b;\nfor (int y = 0; y < height; y++)\n{\nfor (int x = 0; x < width; x++)\n{\n\/\/ Obtaining brightness value\ncol = bmp.GetPixel(x, y);\nr = col.R;\ng = col.G;\nb = col.B;\n\/\/ color reversal\ncol = Color.FromArgb(255 - r, 255 - g, 255 - b);\n\/\/ set up brightness value\nbmp.SetPixel(x, y, col);\n}\n}\n}\nAverage processing time : 27,439msec \n<\/textarea><\/div><div class=\"fusion-text fusion-text-3\"><h3>2. Obtaining pointer (Scan0) at LockBits~UnlockBits, copying the data, processing and re-copying the data based on the result<\/h3>\n<\/div><style type=\"text\/css\" scopped=\"scopped\">.fusion-syntax-highlighter-2 > .CodeMirror, .fusion-syntax-highlighter-2 > .CodeMirror .CodeMirror-gutters {background-color:var(--awb-color1);}.fusion-syntax-highlighter-2 > .CodeMirror .CodeMirror-gutters { background-color: var(--awb-color2); }.fusion-syntax-highlighter-2 > .CodeMirror .CodeMirror-linenumber { color: var(--awb-color8); }<\/style><div class=\"fusion-syntax-highlighter-container fusion-syntax-highlighter-2 fusion-syntax-highlighter-theme-light\" style=\"opacity:0;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:14px;border-width:1px;border-style:solid;border-color:var(--awb-color3);\"><div class=\"syntax-highlighter-copy-code\"><span class=\"syntax-highlighter-copy-code-title\" data-id=\"fusion_syntax_highlighter_2\" style=\"font-size:14px;\">Copy to Clipboard<\/span><\/div><label for=\"fusion_syntax_highlighter_2\" class=\"screen-reader-text\">Syntax Highlighter<\/label><textarea class=\"fusion-syntax-highlighter-textarea\" id=\"fusion_syntax_highlighter_2\" data-readOnly=\"nocursor\" data-lineNumbers=\"1\" data-lineWrapping=\"\" data-theme=\"default\" data-mode=\"text\/x-scss\">\/\/\/ <summary>\n\/\/\/ Obtain the image data at Lock Bits, Unlock Bits with pointer and process the data in sequence \n\/\/\/ <\/summary>\n\/\/\/ <param name=\"bmp\"><\/param>\nprivate void NegativeImage2(Bitmap bmp)\n{\nvar width = bmp.Width;\nvar height = bmp.Height;\n\/\/ Lock Bitmap\nvar bmpData = bmp.LockBits(\nnew Rectangle(0, 0, width, height),\nSystem.Drawing.Imaging.ImageLockMode.ReadWrite,\nbmp.PixelFormat\n);\n\/\/ Obtain Bytes of memory width\nvar stride = Math.Abs(bmpData.Stride);\n\/\/ Arrange image data for saving\nvar data = new byte[stride * bmpData.Height];\n\/\/ Copy Bitmap data\nSystem.Runtime.InteropServices.Marshal.Copy(\nbmpData.Scan0,\ndata,\n0,\nstride * bmpData.Height\n);\nbyte r, g, b;\nint lineIndex = 0;\nfor (int y = 0; y < height; y++)\n{\nfor (int x = 0; x < width * 3; x += 3)\n{\n\/\/ Obtain the brightness value\nr = data[lineIndex + x + 2];\ng = data[lineIndex + x + 1];\nb = data[lineIndex + x]; ;\n\/\/ Set up the brightness value\ndata[lineIndex + x + 2] = (byte)(255 - r);\ndata[lineIndex + x + 1] = (byte)(255 - g);\ndata[lineIndex + x] = (byte)(255 - b);\n}\nlineIndex += stride;\n}\n\/\/ Copy the arrangement as Bitmap data\nSystem.Runtime.InteropServices.Marshal.Copy(\ndata,\n0,\nbmpData.Scan0,\nstride * bmpData.Height\n);\n\/\/ Unlock\nbmp.UnlockBits(bmpData);\n}\nAverage Processing time : 101msec\n<\/textarea><\/div><div class=\"fusion-text fusion-text-4\"><h3>3. Directly read and write on the pointer(Scan0) with ReadByte, WriteByte in Marshal class<\/h3>\n<\/div><style type=\"text\/css\" scopped=\"scopped\">.fusion-syntax-highlighter-3 > .CodeMirror, .fusion-syntax-highlighter-3 > .CodeMirror .CodeMirror-gutters {background-color:var(--awb-color1);}.fusion-syntax-highlighter-3 > .CodeMirror .CodeMirror-gutters { background-color: var(--awb-color2); }.fusion-syntax-highlighter-3 > .CodeMirror .CodeMirror-linenumber { color: var(--awb-color8); }<\/style><div class=\"fusion-syntax-highlighter-container fusion-syntax-highlighter-3 fusion-syntax-highlighter-theme-light\" style=\"opacity:0;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:14px;border-width:1px;border-style:solid;border-color:var(--awb-color3);\"><div class=\"syntax-highlighter-copy-code\"><span class=\"syntax-highlighter-copy-code-title\" data-id=\"fusion_syntax_highlighter_3\" style=\"font-size:14px;\">Copy to Clipboard<\/span><\/div><label for=\"fusion_syntax_highlighter_3\" class=\"screen-reader-text\">Syntax Highlighter<\/label><textarea class=\"fusion-syntax-highlighter-textarea\" id=\"fusion_syntax_highlighter_3\" data-readOnly=\"nocursor\" data-lineNumbers=\"1\" data-lineWrapping=\"\" data-theme=\"default\" data-mode=\"text\/x-scss\">\/\/\/ <summary>\n\/\/\/ How to obtain brightness value with ReadByte, WriteByte in Marshal class\n\/\/\/ <\/summary>\n\/\/\/ <param name=\"bmp\"><\/param>\nprivate void NegativeImage3(Bitmap bmp)\n{\nvar width = bmp.Width;\nvar height = bmp.Height;\n\/\/ Lock the Bitmap\nvar bmpData = bmp.LockBits(\nnew Rectangle(0, 0, width, height),\nSystem.Drawing.Imaging.ImageLockMode.ReadWrite,\nbmp.PixelFormat\n);\n\/\/ Obtain Bytes of memory width\nvar stride = Math.Abs(bmpData.Stride);\nbyte r, g, b;\nint lineIndex = 0;\nvar ptr = bmpData.Scan0;\nfor (int y = 0; y < height; y++)\n{\nfor (int x = 0; x < width * 3; x += 3)\n{\n\/\/ Obtain brightness value\nr = System.Runtime.InteropServices.Marshal.ReadByte(ptr, lineIndex + x + 2);\ng = System.Runtime.InteropServices.Marshal.ReadByte(ptr, lineIndex + x + 1);\nb = System.Runtime.InteropServices.Marshal.ReadByte(ptr, lineIndex + x);\n\/\/ Set up brightness value\nSystem.Runtime.InteropServices.Marshal.WriteByte(ptr, lineIndex + x + 2, (byte)(255 - r));\nSystem.Runtime.InteropServices.Marshal.WriteByte(ptr, lineIndex + x + 1, (byte)(255 - g));\nSystem.Runtime.InteropServices.Marshal.WriteByte(ptr, lineIndex + x, (byte)(255 - b));\n}\nlineIndex += stride;\n}\n\/\/ Unlock\nbmp.UnlockBits(bmpData);\n\nAverage Processing time : 273.6msec\n<\/textarea><\/div><div class=\"fusion-text fusion-text-5\"><h3>4. Directly read and write on the pointer(Scan0) using Unsafe<\/h3>\n<\/div><style type=\"text\/css\" scopped=\"scopped\">.fusion-syntax-highlighter-4 > .CodeMirror, .fusion-syntax-highlighter-4 > .CodeMirror .CodeMirror-gutters {background-color:var(--awb-color1);}.fusion-syntax-highlighter-4 > .CodeMirror .CodeMirror-gutters { background-color: var(--awb-color2); }.fusion-syntax-highlighter-4 > .CodeMirror .CodeMirror-linenumber { color: var(--awb-color8); }<\/style><div class=\"fusion-syntax-highlighter-container fusion-syntax-highlighter-4 fusion-syntax-highlighter-theme-light\" style=\"opacity:0;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:14px;border-width:1px;border-style:solid;border-color:var(--awb-color3);\"><div class=\"syntax-highlighter-copy-code\"><span class=\"syntax-highlighter-copy-code-title\" data-id=\"fusion_syntax_highlighter_4\" style=\"font-size:14px;\">Copy to Clipboard<\/span><\/div><label for=\"fusion_syntax_highlighter_4\" class=\"screen-reader-text\">Syntax Highlighter<\/label><textarea class=\"fusion-syntax-highlighter-textarea\" id=\"fusion_syntax_highlighter_4\" data-readOnly=\"nocursor\" data-lineNumbers=\"1\" data-lineWrapping=\"\" data-theme=\"default\" data-mode=\"text\/x-scss\">\/\/\/ <summary>\n\/\/\/ How to obtain brightness value by using unsafe pointer\n\/\/\/ <\/summary>\n\/\/\/ <param name=\"bmp\"><\/param>\nprivate void NegativeImage4(Bitmap bmp)\n{\nvar width = bmp.Width;\nvar height = bmp.Height;\n\/\/ Bitmap Lock\nvar bmpData = bmp.LockBits(\nnew Rectangle(0, 0, width, height),\nSystem.Drawing.Imaging.ImageLockMode.ReadWrite,\nbmp.PixelFormat\n);\n\/\/ Obtain Bytes of memory width\nvar stride = Math.Abs(bmpData.Stride);\nunsafe\n{\n\/\/ Arrange image data for saving\nvar ptr = (byte*)bmpData.Scan0;\nbyte r, g, b;\nbyte* pLine = ptr;\nfor (int y = 0; y < height; y++)\n{\n\/\/ The first point of the line\nptr = pLine;\nfor (int x = 0; x < width; x++)\n{\n\/\/ Obtain brightness value\nr = ptr[2];\ng = ptr[1];\nb = ptr[0];\n\/\/ Set up brightness value\nptr[2] = (byte)(255 - r);\nptr[1] = (byte)(255 - g);\nptr[0] = (byte)(255 - b);\n\/\/ Move to the next pixel \nptr += 3;\n}\n\/\/ Move to the next line \npLine += stride;\n}\n}\n\/\/ Unlock\nbmp.UnlockBits(bmpData);\n}\nAverage Processing time : 25.4msec\n<\/textarea><\/div><div class=\"fusion-text fusion-text-6\"><h3>5. Read and write with pointer and parallelize the processing using Parallel.For<\/h3>\n<\/div><style type=\"text\/css\" scopped=\"scopped\">.fusion-syntax-highlighter-5 > .CodeMirror, .fusion-syntax-highlighter-5 > .CodeMirror .CodeMirror-gutters {background-color:var(--awb-color1);}.fusion-syntax-highlighter-5 > .CodeMirror .CodeMirror-gutters { background-color: var(--awb-color2); }.fusion-syntax-highlighter-5 > .CodeMirror .CodeMirror-linenumber { color: var(--awb-color8); }<\/style><div class=\"fusion-syntax-highlighter-container fusion-syntax-highlighter-5 fusion-syntax-highlighter-theme-light\" style=\"opacity:0;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:14px;border-width:1px;border-style:solid;border-color:var(--awb-color3);\"><div class=\"syntax-highlighter-copy-code\"><span class=\"syntax-highlighter-copy-code-title\" data-id=\"fusion_syntax_highlighter_5\" style=\"font-size:14px;\">Copy to Clipboard<\/span><\/div><label for=\"fusion_syntax_highlighter_5\" class=\"screen-reader-text\">Syntax Highlighter<\/label><textarea class=\"fusion-syntax-highlighter-textarea\" id=\"fusion_syntax_highlighter_5\" data-readOnly=\"nocursor\" data-lineNumbers=\"1\" data-lineWrapping=\"\" data-theme=\"default\" data-mode=\"text\/x-scss\">\/\/\/ <summary>\n\/\/\/ Parallel processing of the brightness value acquiring setup using usafe pointer\n\/\/\/ <\/summary>\n\/\/\/ <param name=\"bmp\"><\/param>\nprivate void NegativeImage5(Bitmap bmp)\n{\nvar width = bmp.Width;\nvar height = bmp.Height;\n\/\/ Bitmap\uc744 Lock\nvar bmpData = bmp.LockBits(\nnew Rectangle(0, 0, width, height),\nSystem.Drawing.Imaging.ImageLockMode.ReadWrite,\nbmp.PixelFormat\n);\n\/\/ Obtain Bytes of memory width\nvar stride = Math.Abs(bmpData.Stride);\nunsafe\n{\n\/\/ Arrange image data for saving\nvar ptr = (byte*)bmpData.Scan0;\nParallel.For(0, height, y =>\n{\n\/\/ The first pointer of the line\nbyte* pLine = ptr + y * stride;\nfor (int x = 0; x < width; x++)\n{\n\/\/ Obtain brightness value\nbyte r = pLine[2];\nbyte g = pLine[1];\nbyte b = pLine[0];\n\/\/ Set up brightness value\npLine[2] = (byte)(255 - r);\npLine[1] = (byte)(255 - g);\npLine[0] = (byte)(255 - b);\n\/\/ Move to the next pixel\npLine += 3;\n}\n}\n);\n}\n\/\/ Unlock\nbmp.UnlockBits(bmpData);\n}\n\nAverage Processing time : 11.4msec\n<\/textarea><\/div><div class=\"fusion-text fusion-text-7\"><h3>6. Program that brings back the processing<\/h3>\n<\/div><style type=\"text\/css\" scopped=\"scopped\">.fusion-syntax-highlighter-6 > .CodeMirror, .fusion-syntax-highlighter-6 > .CodeMirror .CodeMirror-gutters {background-color:var(--awb-color1);}.fusion-syntax-highlighter-6 > .CodeMirror .CodeMirror-gutters { background-color: var(--awb-color2); }.fusion-syntax-highlighter-6 > .CodeMirror .CodeMirror-linenumber { color: var(--awb-color8); }<\/style><div class=\"fusion-syntax-highlighter-container fusion-syntax-highlighter-6 fusion-syntax-highlighter-theme-light\" style=\"opacity:0;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;font-size:14px;border-width:1px;border-style:solid;border-color:var(--awb-color3);\"><div class=\"syntax-highlighter-copy-code\"><span class=\"syntax-highlighter-copy-code-title\" data-id=\"fusion_syntax_highlighter_6\" style=\"font-size:14px;\">Copy to Clipboard<\/span><\/div><label for=\"fusion_syntax_highlighter_6\" class=\"screen-reader-text\">Syntax Highlighter<\/label><textarea class=\"fusion-syntax-highlighter-textarea\" id=\"fusion_syntax_highlighter_6\" data-readOnly=\"nocursor\" data-lineNumbers=\"1\" data-lineWrapping=\"\" data-theme=\"default\" data-mode=\"text\/x-scss\">pictureBox1.SizeMode = PictureBoxSizeMode.Zoom;\nvar bmp = new Bitmap(@\"C:\\Temp\\syurijou.JPG\"); \/\/ 6000 x 4000 x 24bit\npictureBox1.Image = bmp;\nvar sw = new System.Diagnostics.Stopwatch();\nMessageBox.Show(\"Start\");\nsw.Start();\n\/\/ GetPixel\u3001SetPixel\nNegativeImage1(bmp);\nsw.Stop();\npictureBox1.Refresh();\nMessageBox.Show($\"NegativeImage1: {sw.ElapsedMilliseconds} msec\");\nsw.Reset();\nsw.Start();\n\/\/ Method in consideration of the arrangement\nNegativeImage2(bmp);\nsw.Stop();\npictureBox1.Refresh();\nMessageBox.Show($\"NegativeImage2: {sw.ElapsedMilliseconds} msec\");\nsw.Reset();\nsw.Start();\n\/\/ Mershal\u306eReadByte\u3001WriteByte\nNegativeImage3(bmp);\nsw.Stop();\npictureBox1.Refresh();\nMessageBox.Show($\"NegativeImage3: {sw.ElapsedMilliseconds} msec\");\nsw.Reset();\nsw.Start();\n\/\/ usafe pointer\nNegativeImage4(bmp);\nsw.Stop();\npictureBox1.Refresh();\nMessageBox.Show($\"NegativeImage4: {sw.ElapsedMilliseconds} msec\");\nsw.Reset();\nsw.Start();\n\/\/ parallel processing of usafe pointer\nNegativeImage5(bmp);\nsw.Stop();\npictureBox1.Refresh();\nMessageBox.Show($\"NegativeImage5: {sw.ElapsedMilliseconds} msec\");\n<\/textarea><\/div><\/div><\/div><\/div><\/div><div class=\"fusion-fullwidth fullwidth-box fusion-builder-row-2 fusion-flex-container nonhundred-percent-fullwidth non-hundred-percent-height-scrolling\" style=\"--awb-border-radius-top-left:0px;--awb-border-radius-top-right:0px;--awb-border-radius-bottom-right:0px;--awb-border-radius-bottom-left:0px;--awb-flex-wrap:wrap;\" ><div class=\"fusion-builder-row fusion-row fusion-flex-align-items-flex-start fusion-flex-content-wrap\" style=\"max-width:calc( 1150px + 0px );margin-left: calc(-0px \/ 2 );margin-right: calc(-0px \/ 2 );\"><div class=\"fusion-layout-column fusion_builder_column fusion-builder-column-2 fusion_builder_column_1_1 1_1 fusion-flex-column\" style=\"--awb-bg-size:cover;--awb-width-large:100%;--awb-margin-top-large:0px;--awb-spacing-right-large:0px;--awb-margin-bottom-large:20px;--awb-spacing-left-large:0px;--awb-width-medium:100%;--awb-spacing-right-medium:0px;--awb-spacing-left-medium:0px;--awb-width-small:100%;--awb-spacing-right-small:0px;--awb-spacing-left-small:0px;\"><div class=\"fusion-column-wrapper fusion-flex-justify-content-flex-start fusion-content-layout-column\"><div class=\"fusion-text fusion-text-8\"><h2>Summary<\/h2>\n<h3>Processing time by different processing methods<\/h3>\n<p>It turns out that the processing time by different methods was different, according to the versions and Bit.<br \/>\nWhen operating with 32Bit, there was not much difference between .NET Framework 4.5.2 and 4.7.2, however, upon comparing 32bit and 64bit in the same .NET Frame work version, I could find that 64Bit had gained a relatively faster result.<\/p>\n<ol>\n<li><strong>.NET Framework 4.5.2 &#8211; 32Bit<br \/>\n<\/strong><\/p>\n<table style=\"border-collapse: collapse; width: 61.2734%; height: 144px;\" border=\"1\">\n<tbody>\n<tr style=\"height: 24px;\">\n<td style=\"width: 43.195%; background-color: #1755d1; height: 24px;\"><span style=\"color: #ffffff;\">Method<\/span><\/td>\n<td style=\"width: 18.0899%; background-color: #1755d1; height: 24px;\"><span style=\"color: #ffffff;\">Processing Time (ms)<\/span><\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 43.195%; height: 24px;\">GetPixel, SetPixel<\/td>\n<td style=\"width: 18.0899%; height: 24px;\">27,439<\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 43.195%; height: 24px;\">Processing in consideration of arranging LockBits, UnlockBits<\/td>\n<td style=\"width: 18.0899%; height: 24px;\">101<\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 43.195%; height: 24px;\">ReadByte, WriteByte in Marshal class<\/td>\n<td style=\"width: 18.0899%; height: 24px;\">273.6<\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 43.195%; height: 24px;\">Processing by Unsafe pointer<\/td>\n<td style=\"width: 18.0899%; height: 24px;\">25.4<\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 43.195%; height: 24px;\">Parallel processing by Unsafe pointer<\/td>\n<td style=\"width: 18.0899%; height: 24px;\">11.4<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/li>\n<li><strong>.NET Framework 4.7.2 &#8211; 32Bit<br \/>\n<\/strong><\/p>\n<table style=\"border-collapse: collapse; width: 61.3651%; height: 144px;\" border=\"1\">\n<tbody>\n<tr style=\"height: 24px;\">\n<td style=\"width: 43.3724%; background-color: #1755d1; height: 24px;\"><span style=\"color: #ffffff;\">Method<\/span><\/td>\n<td style=\"width: 18.134%; background-color: #1755d1; height: 24px;\"><span style=\"color: #ffffff;\">Processing Time (ms)<\/span><\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 43.3724%; height: 24px;\">GetPixel, SetPixel<\/td>\n<td style=\"width: 18.134%; height: 24px;\">27,293.4<\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 43.3724%; height: 24px;\">Processing in consideration of arranging LockBits, UnlockBits<\/td>\n<td style=\"width: 18.134%; height: 24px;\">101.8<\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 43.3724%; height: 24px;\">ReadByte, WriteByte in Marshal class<\/td>\n<td style=\"width: 18.134%; height: 24px;\">290.8<\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 43.3724%; height: 24px;\">Processing by Unsafe pointer<\/td>\n<td style=\"width: 18.134%; height: 24px;\">24.4<\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 43.3724%; height: 24px;\">Parallel processing by Unsafe pointer<\/td>\n<td style=\"width: 18.134%; height: 24px;\">9.8<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/li>\n<li><strong>.NET Framework 4.7.2 &#8211; 64bit\u00a0<\/strong><br \/>\n<table style=\"border-collapse: collapse; width: 61.5482%;\" border=\"1\">\n<tbody>\n<tr>\n<td style=\"width: 43.2878%; background-color: #1755d1;\"><span style=\"color: #ffffff;\">Method<\/span><\/td>\n<td style=\"width: 18.3434%; background-color: #1755d1;\"><span style=\"color: #ffffff;\">Processing Time (ms)<\/span><\/td>\n<\/tr>\n<tr>\n<td style=\"width: 43.2878%;\">GetPixel, SetPixel<\/td>\n<td style=\"width: 18.3434%;\">21,281.2<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 43.2878%;\">Processing in consideration of arranging LockBits, UnlockBits<\/td>\n<td style=\"width: 18.3434%;\">85.4<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 43.2878%;\">ReadByte, WriteByte in Marshal class<\/td>\n<td style=\"width: 18.3434%;\">213.6<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 43.2878%;\">Processing by Unsafe pointer<\/td>\n<td style=\"width: 18.3434%;\">27.2<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 43.2878%;\">Parallel processing by Unsafe pointer<\/td>\n<td style=\"width: 18.3434%;\">9.2<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/li>\n<\/ol>\n<h3>[Reference &amp; Caution]<\/h3>\n<ul>\n<li>The contents of this blog are excerpted from the blog (<a href=\"http:\/\/www.imagingsolution.net\">Imaging Solution.net<\/a>) posted by Mr. Akira Yaskawa, who is an engineer working for AVAL DATA. If you need any additional information, please refer to Mr. Akira Yaskawa\u2019s blog directly.<\/li>\n<li>We do not restrict your sharing or referring to this contents, however, using this contents commercially by copying, revising and reproducing without the author\u2019s permission is prohibited.<\/li>\n<li>We do not restrict your use of the contents, however, we are not liable for the occurrence of the bugs from your using the methods shown in this contents.<\/li>\n<\/ul>\n<\/div><\/div><\/div><\/div><\/div><\/p>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":3,"featured_media":4831,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[242],"tags":[253],"class_list":["post-4795","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog-en","tag-c"],"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/aval-global.com\/index.php?rest_route=\/wp\/v2\/posts\/4795","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/aval-global.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/aval-global.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/aval-global.com\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/aval-global.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4795"}],"version-history":[{"count":18,"href":"https:\/\/aval-global.com\/index.php?rest_route=\/wp\/v2\/posts\/4795\/revisions"}],"predecessor-version":[{"id":4858,"href":"https:\/\/aval-global.com\/index.php?rest_route=\/wp\/v2\/posts\/4795\/revisions\/4858"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/aval-global.com\/index.php?rest_route=\/wp\/v2\/media\/4831"}],"wp:attachment":[{"href":"https:\/\/aval-global.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4795"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/aval-global.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4795"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/aval-global.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4795"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}