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 8678943
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T20:50:59+00:00 2026-06-12T20:50:59+00:00

With the following code the image showed as above is converted as below image…

  • 0

enter image description here
With the following code the image showed as above is converted as below image… Their it’s showing black background with gray lines…..i want white background with gray lines ..
Please guide me .. i am new to iPhone
Thanks alot in Advance

- (void)viewDidLoad
{
    [super viewDidLoad];

    // Initialise video capture - only supported on iOS device NOT simulator
#if TARGET_IPHONE_SIMULATOR
    NSLog(@"Video capture is not supported in the simulator");
#else
    _videoCapture = new cv::VideoCapture;
    if (!_videoCapture->open(CV_CAP_AVFOUNDATION))
    {
        NSLog(@"Failed to open video camera");
    }
#endif

    // Load a test image and demonstrate conversion between UIImage and cv::Mat
    UIImage *testImage = [UIImage imageNamed:@"testimage.jpg"];

    double t;
    int times = 10;

    //--------------------------------
    // Convert from UIImage to cv::Mat
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

    t = (double)cv::getTickCount();

    for (int i = 0; i < times; i++)
    {
        cv::Mat tempMat = [testImage CVMat];
    }

    t = 1000 * ((double)cv::getTickCount() - t) / cv::getTickFrequency() / times;

    [pool release];

    NSLog(@"UIImage to cv::Mat: %gms", t);

    //------------------------------------------
    // Convert from UIImage to grayscale cv::Mat
    pool = [[NSAutoreleasePool alloc] init];

    t = (double)cv::getTickCount();

    for (int i = 0; i < times; i++)
    {
        cv::Mat tempMat = [testImage CVGrayscaleMat];
    }

    t = 1000 * ((double)cv::getTickCount() - t) / cv::getTickFrequency() / times;

    [pool release];

    NSLog(@"UIImage to grayscale cv::Mat: %gms", t);

    //--------------------------------
    // Convert from cv::Mat to UIImage
    cv::Mat testMat = [testImage CVMat];

    t = (double)cv::getTickCount();

    for (int i = 0; i < times; i++)
    {
        UIImage *tempImage = [[UIImage alloc] initWithCVMat:testMat];
        [tempImage release];
    }

    t = 1000 * ((double)cv::getTickCount() - t) / cv::getTickFrequency() / times;

    NSLog(@"cv::Mat to UIImage: %gms", t);

    // Process test image and force update of UI 
    _lastFrame = testMat;
    [self sliderChanged:nil];
}
- (IBAction)capture:(id)sender
{
    if (_videoCapture && _videoCapture->grab())
    {
        (*_videoCapture) >> _lastFrame;
        [self processFrame];
    }
    else
    {
        NSLog(@"Failed to grab frame");        
    }
}
- (void)processFrame
{
    double t = (double)cv::getTickCount();

    cv::Mat grayFrame, output;

    // Convert captured frame to grayscale
    cv::cvtColor(_lastFrame, grayFrame, cv::COLOR_RGB2GRAY);

    // Perform Canny edge detection using slide values for thresholds
    cv::Canny(grayFrame, output,
              _lowSlider.value * kCannyAperture * kCannyAperture,
              _highSlider.value * kCannyAperture * kCannyAperture,
              kCannyAperture);

    t = 1000 * ((double)cv::getTickCount() - t) / cv::getTickFrequency();

    // Display result 
    self.imageView.image = [UIImage imageWithCVMat:output];
    self.elapsedTimeLabel.text = [NSString stringWithFormat:@"%.1fms", t];
}

enter image description here

  • 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-06-12T20:51:00+00:00Added an answer on June 12, 2026 at 8:51 pm

    Inverting a grayscale 1-channel Mat is:

    Mat invertedOutput = 255 - output;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code a.rollover { background-image: url('sprite.jpg'); display: block; width: 191px; height:
I've used the following code for background image of body tag. background-image: url(images/taling.gif); background-repeat:repeat-x;
I was originally using the following code: background-image: url(../images/tabbottom.gif); background-repeat: no-repeat; background-position: left bottom;
I have the following code: Image tmpimg = null; HttpWebRequest httpWebRequest = (HttpWebRequest)HttpWebRequest.Create(url); HttpWebResponse
I have following code for loading image from url in xml parsing endElement method
I am having following code for getting image from the web: NSURL *ImageURL =
Following code is to save image took from camera into photo album. if ([mediaType
I use the following code to crop an image according to a rectangular selection
I'm using the following code to load an image and associated image map: <span><%=
I have the following code that simply moves my image across the screen: /*

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.