Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7158053
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T12:59:49+00:00 2026-05-28T12:59:49+00:00

I am creating an image processing application in C# and trying to take advantage

  • 0

I am creating an image processing application in C# and trying to take advantage of my multicored system by performing the bulk of the processing in parallel. Specifically, I have a Parallel.For loop that walks through each pixel and applies a Gaussian filter. Just performing the calculations, I see a significant speed up, as expected, but the problem comes when trying to save the results of the computations. The code looks something like this:

Parallel.For(// various loop parameters
{
    // processing and number crunching
    // significant speed up here
    .
    .
    .
    bitmap.SetPixel(x, y, value); 
});

This gives a runtime error because multiple threads end up trying to write to the bitmap object at the same time. I locked the object as follows:

lock(bitmap)
    bitmap.SetPixel(x, y, value); 

But this ends up being slower than the serial version. After examining it, it turns out the call to SetPixel takes about 90% of the run time for each loop iteration, meaning that the separate threads were spending the bulk of their time waiting to acquire the lock on the bitmap object, and the added overhead of having multiple threads slowed it down.

So what I want to know is, is there a way to have multiple threads concurrently write to the same object? I am careful that each thread is working on a different part of the image, so no race condition would be introduced by this. Is there any way to override the error that’s being thrown and say, “I know what I’m doing is unsafe, but I want to do it anyways?” Something like the Concurrency::combinable class seems like it might do the trick, but that’s only in C++.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T12:59:49+00:00Added an answer on May 28, 2026 at 12:59 pm

    If you are filtering in the whole image you should consider locking the bitmap, copying the image data to an array and then concurrently updating the array data instead of calling SetPixel.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm creating a Java application for image processing , and after a while of
I am creating a simple image processing application using OpenCV / Qt and I
I am new in c#. I am working on image processing. I am creating
I have been creating an image gallery with jQuery, all is done. The images
I am creating a basic image browsing application using Silverlight. Depending on the user's
I am a newbie in image processing and I have taken a project of
I'm creating an image gallery site that you have to log in to access.
I have created a Class Library (called as GNGEngine.dll) which performs some image processing
Currently I'm learning C++ and I've been trying to create a simple image processing
I'm creating a performance-critical application that implements image manipulation. I'm using some pixel pointers

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.