imread directely into Roi?

6 views
Skip to first unread message

gabor

unread,
Jun 25, 2010, 10:20:29 AM6/25/10
to ctypes-opencv
I have 2 images: A,B of same size w,h
I want to compose them into a wide image AB of size (w+w,h)
I use the following code:

AB=cv.Mat(cv.Size2i(2*w, h),cv.CV_8UC3)
#copy left part
roi=cv.Rect(0,0,w,h)
img=AB(roi)
tmp=imread("A",1)
tmp.copyTo(img)
#copy right part
roi=cv.Rect(w,0,w,h)
img=AB(roi)
tmp=imread("B",1)
tmp.copyTo(img)
#dispose tmp

I cannot write it like -

roi=cv.Rect(0,0,w,h)
img=AB(roi)
img=imread("A",1)

because 'assigning' in Python is just aliasing.

How can I save this unnecessary copying of array (which means writing
everything twice)?
Thanks

Minh-Tri Pham

unread,
Jul 9, 2010, 6:59:06 PM7/9/10
to ctypes...@googlegroups.com
Hi gabor,

Have you tried 'tmp.assignTo(img)'?

Cheers,
Minh-Tri

--
Dr. Minh-Tri Pham
Research Fellow, University of Surrey, UK
Email: t.p...@surrey.ac.uk or pmt...@gmail.com
Mob: +44 (0) 778 774 1089 | Tel: +44 (0) 148 368 4711

info gabor

unread,
Jul 11, 2010, 8:24:43 AM7/11/10
to ctypes...@googlegroups.com

Thanks, Minh-Tri.

I tried 'tmp.assignTo(img)' - but it didn't work.

I need a way to read directly into an existing Mat, defined as roi of another Mat. I think it should be defined somehow as a destination to imread.
T%hanks again,
Gabor

 


On Sat, Jul 10, 2010 at 1:59 AM, Minh-Tri Pham <pmt...@gmail.com> wrote:
Hi gabor,

Have you tried 'tmp.assignTo(img)'?

Cheers,

--
You received this message because you are subscribed to the Google Groups "ctypes-opencv" group.
To post to this group, send email to ctypes...@googlegroups.com.
To unsubscribe from this group, send email to ctypes-openc...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/ctypes-opencv?hl=en.


Minh-Tri Pham

unread,
Jul 11, 2010, 1:56:18 PM7/11/10
to ctypes...@googlegroups.com
IIRC, the ROI concept is no longer supported in OpenCV's C++ interface. How
about doing it in the 'numpy' way? E.g.

import numpy as np
C = asMat(np.concatenate([A[:], B[:]]))

Minh-Tri

> Email: t.p...@surrey.ac.uk <mailto:t.p...@surrey.ac.uk> or
> pmt...@gmail.com <mailto:pmt...@gmail.com>


> Mob: +44 (0) 778 774 1089 | Tel: +44 (0) 148 368 4711
>
> --
> You received this message because you are subscribed to the Google Groups
> "ctypes-opencv" group.
> To post to this group, send email to ctypes...@googlegroups.com

> <mailto:ctypes...@googlegroups.com>.


> To unsubscribe from this group, send email to
> ctypes-openc...@googlegroups.com

> <mailto:ctypes-opencv%2Bunsu...@googlegroups.com>.


> For more options, visit this group at
> http://groups.google.com/group/ctypes-opencv?hl=en.
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "ctypes-opencv" group.
> To post to this group, send email to ctypes...@googlegroups.com.
> To unsubscribe from this group, send email to
> ctypes-openc...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/ctypes-opencv?hl=en.

--

Reply all
Reply to author
Forward
0 new messages