Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

[open] Spectrum image, from what participants can choose colors. It is possible?

edited February 2013 in OpenSesame

Hello,

I need to design an experiment, in that participants could choose a color from a spectrum of colors image. I need something like in photoshop (when you choose what colour to use), and that the color of that region where is mouse pointer to be seen in a square on the bottom corner of the display, and that colour need to be registered after normal mouse click on the choosed color.
Is possible to do something like this in OpenSesame?

PS: Sorry if my description is not so clear... :)

Comments

  • edited February 2013

    Hi,

    This would be a handy tool for research on synesthesia (for example), but currently such a tool does not exist. You might want to look at inline_scripting, especially the canvas functions: http://osdoc.cogsci.nl/python-inline-code/canvas-functions/

    If you're not so great at Python, this might be a good opportunity to learn ;) Otherwise, it shouldn't be too difficult :)

    Good luck!

  • edited 5:45PM

    The easiest approach is probably to just use an image that is exactly the size of the display. That way you don't have to read the contents of the screen (which is hard), but can simply extract the contents from the image (which is easy). Perhaps this script will get you started. It reads an image called my_image.jpg from the file pool and goes into 'photoshop mode' until you click a button.

    from PIL import Image
    from openexp.mouse import mouse
    from openexp.canvas import canvas
    
    # Load an image from the file pool. This image must have the same
    # dimensions as the display resolution of the experiment!
    # See: http://www.pythonware.com/library/pil/handbook/image.htm
    src = exp.get_file('my_image.jpg') 
    img = Image.open(src)
    
    # Create a mouse object and make the cursor visible
    # See: http://osdoc.cogsci.nl/python-inline-code/mouse-functions/
    mouse = mouse(exp)
    mouse.set_visible(True)
    
    # Create a canvas object
    # See: http://osdoc.cogsci.nl/python-inline-code/canvas-functions/
    canvas = canvas(exp)
    
    # Loop infinitely
    while True:
        # Get the mouse position
        pos, time = mouse.get_pos()
        # Get the color of the image at the mouse position
        col = img.getpixel(pos)
        # Draw a canvas with the image and a rectangle with the extracted color
        canvas.clear()
        canvas.image(src)
        canvas.rect(10, 10, 100, 100, color=col, fill=True)
        canvas.show()
        # Break the loop if a button is clicked
        if mouse.get_click(timeout=1)[0] != None:
            break
    

    If you're not so great at Python, this might be a good opportunity to learn

    But this is definitely true! You will probably want to (at least) tweak this script, and this will require knowledge of Python. A good start:

    Cheers!
    Sebastiaan

Sign In or Register to comment.

agen judi bola , sportbook, casino, togel, number game, singapore, tangkas, basket, slot, poker, dominoqq, agen bola. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 50.000 ,- bonus cashback hingga 10% , diskon togel hingga 66% bisa bermain di android dan IOS kapanpun dan dimana pun. poker , bandarq , aduq, domino qq , dominobet. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 10.000 ,- bonus turnover 0.5% dan bonus referral 20%. Bonus - bonus yang dihadirkan bisa terbilang cukup tinggi dan memuaskan, anda hanya perlu memasang pada situs yang memberikan bursa pasaran terbaik yaitu http://45.77.173.118/ Bola168. Situs penyedia segala jenis permainan poker online kini semakin banyak ditemukan di Internet, salah satunya TahunQQ merupakan situs Agen Judi Domino66 Dan BandarQ Terpercaya yang mampu memberikan banyak provit bagi bettornya. Permainan Yang Di Sediakan Dewi365 Juga sangat banyak Dan menarik dan Peluang untuk memenangkan Taruhan Judi online ini juga sangat mudah . Mainkan Segera Taruhan Sportbook anda bersama Agen Judi Bola Bersama Dewi365 Kemenangan Anda Berapa pun akan Terbayarkan. Tersedia 9 macam permainan seru yang bisa kamu mainkan hanya di dalam 1 ID saja. Permainan seru yang tersedia seperti Poker, Domino QQ Dan juga BandarQ Online. Semuanya tersedia lengkap hanya di ABGQQ. Situs ABGQQ sangat mudah dimenangkan, kamu juga akan mendapatkan mega bonus dan setiap pemain berhak mendapatkan cashback mingguan. ABGQQ juga telah diakui sebagai Bandar Domino Online yang menjamin sistem FAIR PLAY disetiap permainan yang bisa dimainkan dengan deposit minimal hanya Rp.25.000. DEWI365 adalah Bandar Judi Bola Terpercaya & resmi dan terpercaya di indonesia. Situs judi bola ini menyediakan fasilitas bagi anda untuk dapat bermain memainkan permainan judi bola. Didalam situs ini memiliki berbagai permainan taruhan bola terlengkap seperti Sbobet, yang membuat DEWI365 menjadi situs judi bola terbaik dan terpercaya di Indonesia. Tentunya sebagai situs yang bertugas sebagai Bandar Poker Online pastinya akan berusaha untuk menjaga semua informasi dan keamanan yang terdapat di POKERQQ13. Kotakqq adalah situs Judi Poker Online Terpercayayang menyediakan 9 jenis permainan sakong online, dominoqq, domino99, bandarq, bandar ceme, aduq, poker online, bandar poker, balak66, perang baccarat, dan capsa susun. Dengan minimal deposit withdraw 15.000 Anda sudah bisa memainkan semua permaina pkv games di situs kami. Jackpot besar,Win rate tinggi, Fair play, PKV Games