lucasb-eyer / pydensecrf

Python wrapper to Philipp Krähenbühl's dense (fully connected) CRFs with gaussian edge potentials.
MIT License
1.94k stars 413 forks source link

Error when using own image for addPairwiseBilateral #32

Closed raymondchua closed 7 years ago

raymondchua commented 7 years ago

Hi, I have tried to use my own image for the addPairwiseBilateral(sxy=80, srgb=13,, rgbim=own_image,compat=10) but I keep getting the following error. I have tried reading my image from OpenCV as well as skimage. My image dtype and shape returns the following:

uint8
(315, 480, 3)

And below is the error. Has anyone faced this before?

Traceback (most recent call last):
  File "postCRF.py", line 60, in <module>
    main()
  File "postCRF.py", line 54, in main
    d.addPairwiseBilateral(sxy=80, srgb=13, rgbim=image_sk, compat=10)
  File "pydensecrf/densecrf.pyx", line 118, in pydensecrf.densecrf.DenseCRF2D.addPairwiseBilateral (pydensecrf/densecrf.cpp:4343)
ValueError: Bad shape for pairwise bilateral (Need (480, 315, 3), got [315, 480, 3, 0, 0, 0, 0, 0])
raymondchua commented 7 years ago

Nevermind, I fixed it. Apparently I have to create my DenseCRF2D as

d = dcrf.DenseCRF2D(480, 315, NUM_CLASS)