image processing

48 views
Skip to first unread message

avi kaur

unread,
Jun 29, 2015, 5:45:37 AM6/29/15
to sage-s...@googlegroups.com


Hello everybody


I am trying to make histogram of image. I wrote the following code for that:


import cv2
img=cv2.imread('avi.jpg')
gray= cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
his=cv2.clacHist([img],[0],None,[256],[0,256])

then I am receiving the following error:
---------------------------------------------------------------------------
SystemError                               Traceback (most recent call last)
<ipython-input-12-732fd14676fa> in <module>()
----> 1 hist = cv2.calcHist(gray,[Integer(0)],None,[Integer(256)],[Integer(0),Integer(256)])

SystemError: error return without exception set


What is my mistake?

--
Avi kaur

kcrisman

unread,
Jun 29, 2015, 8:58:28 AM6/29/15
to sage-s...@googlegroups.com, kaura...@gmail.com
his=cv2.clacHist([img],[0],None,[256],[0,256])

then I am receiving the following error:
---------------------------------------------------------------------------
SystemError                               Traceback (most recent call last)
<ipython-input-12-732fd14676fa> in <module>()
----> 1 hist = cv2.calcHist(gray,[Integer(0)],None,[Integer(256)],[Integer(0),Integer(256)])

SystemError: error return without exception set


The error is very vague, but a first guess is that cv2 can't handle Sage Integers.  So using int(256) and int(0) might help.

More generally, if you are not going to be using a lot of Sage-specific functionality but mostly Python packages, you may want to try using 

sage -ipython 

in the command line, or as a notebook, the IPython notebook included in Sage (which you can also still use Sage from, I believe).

avi kaur

unread,
Jun 30, 2015, 2:44:13 AM6/30/15
to sage-s...@googlegroups.com
On Mon, Jun 29, 2015 at 6:28 PM, kcrisman <kcri...@gmail.com> wrote:
>> his=cv2.clacHist([img],[0],None,[256],[0,256])
>>
>> then I am receiving the following error:
>>
>> ---------------------------------------------------------------------------
>> SystemError Traceback (most recent call
>> last)
>> <ipython-input-12-732fd14676fa> in <module>()
>> ----> 1 hist =
>> cv2.calcHist(gray,[Integer(0)],None,[Integer(256)],[Integer(0),Integer(256)])
>>
>> SystemError: error return without exception set
>>
>
> The error is very vague, but a first guess is that cv2 can't handle Sage
> Integers. So using int(256) and int(0) might help.
>
> More generally, if you are not going to be using a lot of Sage-specific
> functionality but mostly Python packages, you may want to try using
>
> sage -ipython

I tried it with sage -ipython and as a result it shows vertical
line. It does not show histogram :(.


--
Avi kaur
Blog: https://avikashyap620.wordpress.com
"There is no lacking of opportunity, The thing is you do not want to see It"

>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "sage-support" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/sage-support/s7fM---nxmc/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> sage-support...@googlegroups.com.
> To post to this group, send email to sage-s...@googlegroups.com.
> Visit this group at http://groups.google.com/group/sage-support.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages