Question: make a c# programm for windonsFormApp ( visual code studio ) on the form that binarizes so that, 1 ) the image displayed as a
make a c# programm for windonsFormAppvisual code studio on the form that binarizes so that, the image displayed as a preview has about the same resolution as the picturebox it is displayed in downsampling to speed up the preview with the different thresholds there is a button for threshold selection with Otsu's algorithm. For otsu i have this private static float Pxint init, int end, int hist
int sum ;
int i;
for i init; i end; i
sum histi;
return floatsum;
private static float Mxint init, int end, int hist
int sum ;
int i;
for i init; i end; i
sum i histi;
return floatsum;
private static int FindMaxfloat vec, int n
float maxVec ;
int idx ;
int i;
for i ; i n ; i
if veci maxVec
maxVec veci;
idx i;
return idx;
unsafe private static void GetHistogrambyte p int w int h int ws int hist
hist.Initialize;
for int i ; i h; i
for int j ; j w ; j
int index i ws j;
histpindex;
public static int GetOtsuThresholdBitmap bmp
byte t ;
float vet new float;
int hist new int;
vet.Initialize;
float p p p;
int k;
BitmapData bmData bmpLockBitsnew Rectangle bmpWidth, bmpHeight
ImageLockMode.ReadOnly, PixelFormat.FormatbppRgb;
unsafe
byte p bytevoidbmDataScanToPointer;
GetHistogramp bmpWidth, bmpHeight, bmData.Stride, hist;
for k ; k ; k
p Px k hist;
p Pxk hist;
p p p;
if p
p;
float diff Mx k hist pMxk hist p;
vetkfloatdiff diff p;
bmpUnlockBitsbmData;
t byteFindMaxvet;
return t;
i think it needs formform and class thank you
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
