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

  • SEARCH
  • Home
  • 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 8244121
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T21:44:30+00:00 2026-06-07T21:44:30+00:00

I’m trying to learn OpenCV and I want to apply this simple formula: That

  • 0

I’m trying to learn OpenCV and I want to apply this simple formula:
enter image description here

That is a per-pixel operation and transform the pixel from r to s.

This is my code:

int main(int /*argc*/, char** /*argv*/) {

    Mat _img = imread("lena.jpg"); 
    cvtColor(_img, img, CV_32F);

    cout << "original image size: " << img.rows << " " << img.cols << endl;
    cout << "original type: " << img.type() << endl;
    cout << "original depth: " << img.depth() << endl;

    Mat _src = img.clone();
    _src += 1;
    log(_src, logContrast);
    logContrast *= log_c;

    /// ...

And I get this error:

OpenCV Error: Assertion failed (depth == CV_32F || depth == CV_64F) in log, file /home/user/Documents/Code/OpenCV-2.3.1/modules/core/src/mathfuncs.cpp, line 1772
terminate called after throwing an instance of 'cv::Exception'
  what():  /home/alberto/Documents/Code/OpenCV-2.3.1/modules/core/src/mathfuncs.cpp:1772: error: (-215) depth == CV_32F || depth == CV_64F in function log

I tried with gray and coloured image, and with cvtColor with CV_8U, CV_32F and C1, C3, but I cout always 0 as depth..

I’ve spent hours on OpenCV manuals and on OpenCV-2.3.1/modules/core/include/opencv2/core/ types_c.h but.. I can’t find a solution. I think I’ve done some confusion on how transform depth of a Mat object.

  • 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-07T21:44:33+00:00Added an answer on June 7, 2026 at 9:44 pm

    are you sure you converted the image to float32 ?

    Please check out the code below, i just wrote. Don’t know if output is correct, but it didn’t throw any errors.

    #include "opencv2/highgui/highgui.hpp"
    #include "opencv2/imgproc/imgproc.hpp"
    #include <iostream>
    using namespace std;
    
    int main ()
    {
        cv::Mat binary = cv::imread("kick.jpg",0);
    
        cv::Mat fg;
        binary.convertTo(fg,CV_32F);
        fg = fg + 1;
        cv::log(fg,fg);
        cv::convertScaleAbs(fg,fg);
        cv::normalize(fg,fg,0,255,cv::NORM_MINMAX);
        cv::imshow("a",fg);
    cv::waitKey(0);
    }
    

    And below is the output i got :

    enter image description here

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am doing a simple coin flipping experiment for class that involves flipping a
I have a French site that I want to parse, but am running into
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to create an if statement in PHP that prevents a single post
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has

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.