Grayscale image from binary data

Grayscale image from binary data

By : user2948516
Date : November 14 2020, 04:51 PM
will help you A good way and with a good performance is to use LockBits function to access image data, using the LockBits you can create a Bitmap image using each byte of image, the lockBit lock the image data in memory to change each pixel data of the Bitmap Image. See this example:
code :
  Bitmap bm = new Bitmap(512, 512);
  BitmapData bmd=bm.LockBits(new Rectangle(0, 0, 10, 10), System.Drawing.Imaging.ImageLockMode.ReadOnly, bm.PixelFormat);
  int PixelSize=4;

  for(int y=0; y<bmd.Height; y++)
    byte* row=(byte *)bmd.Scan0+(y*bmd.Stride);
    for(int x=0; x<bmd.Width; x++)
      // Here you change your pixel data
// concatenate 
pict1.Image = bmp;
// Draw using CreateGraphics
Graphics g = Graphics.FromHwnd(pictureBox1.Handle);
g.DrawImage(bmp, new Point(10, 10));
// Average value between channels
Color oc = bmp.GetPixel(i, x);
int grayScale = (int)((oc.R * 0.3) + (oc.G * 0.59) + (oc.B * 0.11));
Color nc = Color.FromArgb(oc.A, grayScale, grayScale, grayScale);
d.SetPixel(x, y, nc); // if you are using bitmap
// value from one channel
Color pixelColor = c.GetPixel(x, y);
Color newColor = Color.FromArgb(pixelColor.R, pixelColor.R, pixelColor.R);
c.SetPixel(x, y, newColor); // Now greyscale

Share : facebook icon twitter icon
Create an image (bmp or so) from byte array containing 8bit(grayscale) or 1bit(binary) data in Java

Create an image (bmp or so) from byte array containing 8bit(grayscale) or 1bit(binary) data in Java

By : Prasanna Desai
Date : March 29 2020, 07:55 AM
wish help you to fix your issue In a slightly similar situation I used Raster with BufferedImage. See this simple example with gray scale 8 bit:
code :
public static void main(String[] args) {
    JFrame f = new JFrame();
    f.setSize(600, 400);
    f.getContentPane().setLayout(new BorderLayout());
    BufferedImage bi = new BufferedImage(200, 100, BufferedImage.TYPE_BYTE_GRAY);
    WritableRaster wr = bi.getRaster();
    for (int col=0; col<bi.getWidth(); col++) {
        for (int row=0; row<bi.getHeight(); row++) {
            wr.setPixel(col, row, new int[] {(col+row)&0xff});
    JLabel l = new JLabel(new ImageIcon(bi));
    f.getContentPane().add(l, BorderLayout.CENTER);
Vectorization of binary grayscale image

Vectorization of binary grayscale image

By : Harold Snel
Date : March 29 2020, 07:55 AM
it fixes the issue Perhaps cubic bezier is what you need:
This is a project I've done, (1) I use Ramer-Douglas-Peucker to remove noise and (2) represent the curves as cubic bezier I obtain by using least square fitting:
JavaCV - invert grayscale image, or convert binary back to grayscale

JavaCV - invert grayscale image, or convert binary back to grayscale

By : thomas
Date : March 29 2020, 07:55 AM
it should still fix some issue I think there was a mistake in the code, and actually HoughLinesP can be called with an 8U input image.
How do I invert a grayscale image and convert it to a binary image?

How do I invert a grayscale image and convert it to a binary image?

By : stelios
Date : March 29 2020, 07:55 AM
I hope this helps you . It depends on what type your input matrix is.
If it is a logical matrix you can simply use
thresholding grayscale image without converting binary image

thresholding grayscale image without converting binary image

By : fuzz
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further I would like to know how can ı achieve thresholding based on grayscale intensity by not converting it to binary image. As an example, below 50 intensity will be 0 while 50-255 intensity values remain the same(in Matlab). , Check the following...
Read sample image:
Related Posts Related Posts :
  • Why does C# also not allow empty conditions in while loops?
  • Unable to get a block of code into my regex match groups
  • What is difference between dbcontext.Add and dbcontext.AddObject
  • How do I update the file version number of C# DLL without recompiling?
  • Value for html control always null
  • HttpClient hangs when timeout is setting (Windows Phone)
  • Handle Multiple Form tag in asp.net page?
  • create word document with html content in c#
  • Confusion about Find And Replace
  • Format sms messages in Clickatell
  • Automated Function Overload
  • String to date in MS Access SQL statement gives type mismatch error
  • ShowDialog exiting on certain events
  • Is there a try Convert.ToInt32... avoiding exceptions
  • How to move wpf application into minimize tray at Window Start-up C#?
  • How to change display format of long variable?
  • How to use Addfields in MongoDB C# Aggregation Pipeline
  • MsTest TestCleanup method not called when an unhandled exception is thrown
  • missing last data when exporting gridview to excel
  • How to add array of objects to List in c#
  • Lambda Expression to order (sort) my list collection
  • Library for displaying music notation
  • How to compare two dictionaries in c# and get the output as True and False after validation
  • specify fields to be serialized with JSON
  • How do you obtain the content of a specific node using XmlDocument in C#?
  • How to ignore the first line in a csv file when you read the csv file in C#
  • c# - Problem calling public void from class
  • How to tell a class which objects it should create? Type vs. object confusion :(
  • Save CheckBox state to xml
  • WIX CAQuietExec NETSH Command Fails
  • Issues sending http put request every 60 seconds to RoR app
  • ConfigurationManager.ConnectionStrings.ConnectionString Issue
  • Real size WPF controls for printing
  • How to cancel properly?
  • C# String multiplication error
  • Using Solrnet and Assigning Attributes with Entity Framework Generated POCOs
  • Regex pattern for single backslash
  • TextBox: insert spaces for credit card number?
  • C# DLL loaded for exe-application is not found when launching similar DLL by rundll32.exe
  • Debug a Windows Service with WCF library
  • Open a file from an external assembly?
  • Servicestack RegistrationFeature Unable to bind request
  • Index was outside the bounds of the array confusion
  • Error in Xml to List code. The ':' character, hexadecimal value 0x3A, cannot be included in a name
  • I am trying to do a while loop with a string conditional statement in C#
  • C# 'Cannot access a disposed object. Object name: 'SslStream'.'
  • How to make Gecko use seperate CookieContainer per instance?
  • C# Advanced form "please wait"
  • Send and Receive data C# using network stream
  • How to discover that appsettings changed in C#?
  • Check what needs full trust
  • What is the execution order of an MVC Razor view/layout
  • Table designer (Entity Framework) is too resource intense
  • How to clean up an exception string so it can be displayed via Javascript Alert?
  • Configuring Amazon SES Feedback Notifications via Amazon SNS in ASP.NET MVC (C#)
  • C# api responce and request
  • Dynamodb putitem function not working properly
  • theme in windows phone(light or dark) using c#
  • Backup attached database file(.mdf) using c# and SQL Server
  • What is 'TextFile' and where it is uses in WPF project
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org