Opencv_contrib: Mismatch between code and documentation in anisotropicDifussion funciton

Created on 22 Jan 2019  路  11Comments  路  Source: opencv/opencv_contrib

System information (version)
  • OpenCV => 4.0.0
  • Operating System / Platform => Debian on Windows 10(WSL)
  • Compiler => python3 interpreter
Detailed description

Hi,

There appears to be mismatch between the official documentation here and the anisotropicDiffusion function defined here. The document mentions that source image should be grayscale but the assert statement in line 251 checks if the source image has 3 channels.

Steps to reproduce

import cv2
image = cv2.imread('image.png')
grayscale = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
filtered_image = cv2.ximgprox.anisotropicDiffusion(grascale, 0.25, 10, 1000)

I get the following error:
cv2.error: OpenCV(4.0.0) /io/opencv_contrib/modules/ximgproc/src/anisodiff.cpp:251: error: (-215:Assertion failed) src_.dims() == 2 && type == CV_8UC3 in function 'anisotropicDiffusion'

documentation ximgproc good first issue

All 11 comments

Documentation should be changed to fit source code. That is the simplest change to make.

Should someone work on a grayscale variant of the code though?

It should be doable from my understanding. I have asked @alalek here and he hasn't responded so far.

I had already marked this as documentation issue 7 days ago.

@alalek True. But shouldn't it be the case that this algorithm be implemented for gray scale images as well ? Because if I remember correctly, the underlying theory is the same for both.

I skimmed this because it came up as a question on IRC. I have no interest either way in this algorithm and code, so you know where I'm coming from.

The code has the beginnings of multi-channel, but the inner loops are hard-coded for three channels (with obvious patterns). To me it looks definitely doable to take this code, copy it, and strip the copy down to single-channel. What I don't know is the preferred way to lay this out in source. Without any guidance, I'd just make it two static functions to do the work (1ch and 3ch) and run assertions and dispatch in the public function.

@alalek . Should I work on this code changes . I have never contributed before to opencv-contrib but it does seems doable.

According to me in this issue, we have to make changes in the documentation where it says that the function inputs a grayscale image instead it should be an image of three channels. Am I saying correctly?

How can I make changes to the documentation if I am correct?

I think that : first(pull request 1) documentation must be changed and later (pull request 2) code could be changed and then doucumentation updated with new functionality

I am new to open source, can you tell me which files to look in to for making changes in the documentation?

@kyscg Your changes were the same as my previous PR. I would recommend creating a new PR if there are other changes.

Was this page helpful?
0 / 5 - 0 ratings