C# - Fast Image Processing using Lockbits() and Marshal.Copy() Method

Posted by ေတဇာလင္း Sunday 29 January 2017 0 comments

မိတ္ေဆြ၊ ညီအစ္ကို၊ ေမာင္ႏွမမ်ား အားလံုးပဲ မဂၤလာပါဗ်ာ။ ဒီေန႔ေတာ့ က်ေနာ္တို႔ Visual Studio C# ကို အသံုးျပဳၿပီး Image Processing အတြက္ pixel နဲ႔ Color တန္ဖိုးေတြကို လ်င္လ်င္ျမန္ျမန္ Detect လုပ္ႏိုင္မရ္႕ Lockbits( ) and Marshal.Copy( ) Mehtod အေၾကာင္းေလးကို ေလ့လာၾကည့္ပါ့မရ္။ Processing အတြက္ကိုေတာ့ ေရွ႕သင္ခန္းစာမွာ ေလ့လာခဲ့ၿပီးျဖစ္တဲ့ Image Color Channel ခြဲထုတ္တာကိုပဲ သံုးထားပါတရ္။ ေရွ႕သင္ခန္းစာမွာတုန္းကေတာ့ Detection and Procesing အတြက္ GetPixel( ) နဲ႔ SetPixel( ) Method ကို သံုးျပထားပါတရ္။ ဒီ Method ႏွစ္ခုက Image Processing မွာ Pixel and Color Detection အတြက္ အရိုးရွင္းဆံုးနဲ႔ အေျခခံအက်ဆံုး Method ေတြပါ။ Processing Time လည္း အရမ္းေႏွးပါတရ္။ ဒါေၾကာင့္ Image Processing ကုိေလ့လာတဲ့အခါမွာ အသံုးျပဳဖို႔ အဆင္မေျပလွပါဘူး။ ဥပမာအေနနဲ႔ ေရွ႕သင္ခန္းစာ Color Channel - 1024x768 Resolution ရွိတဲ့ Image တစ္ခုကို Channel ခြဲတဲ့အခါမွာ Processing Time 2045ms (2 Second သာသာေပါ့။ မိမိ ကြန္ပ်ဴတာရဲ႕ Processing Speed ေပၚမွာလည္း မူတည္ပါေသးတရ္ဗ်)ေလာက္ ၾကာပါတရ္။ ဒါဆို Resolution မ်ားမ်ားနဲ႔ Advanced Processing အတြက္ ဘရ္လိုမွ အဆင္ေျပႏိုင္ဖို႔ မရွိပါဘူး။ ဒီျပႆနာကို တနည္းတဖံု ေျဖရွင္းႏိုင္ဖို႔အတြက္ Lockbits( ) Method ကို ေလ့လာရတာပါ။
စိတ္၀င္စားတဲ့ မိတ္ေဆြ၊ ညီအစ္ကုိ၊ ေမာင္ႏွမမ်ား က်ေနာ္နဲ႔အတူ ေလ့လာၾကည့္ၾကအံုးစို႔ဗ်ာ။
နားလည္ႏိုင္ၾကလိမ့္မရ္လို႔ ေမ်ာ္လင့္ပါတရ္ဗ်။ မိတ္ေဆြ၊ ညီအစ္ကို၊ ေမာင္ႏွမအားလံုး ေလ့လာျခင္းျဖင့္ ေက်နပ္ႏိုင္ၾကပါေစ။

0 Responses so far.

Post a Comment