NTNUJAVA Virtual Physics Laboratory
Enjoy the fun of physics with simulations!
Backup site http://enjoy.phy.ntnu.edu.tw/ntnujava/
November 24, 2017, 07:02:20 am *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register  
Brevity is the Soul of wit. ..."Shakespeare (154-1616, English dramatist and poet) "
Google Bookmarks Yahoo My Web MSN Live Netscape Del.icio.us FURL Stumble Upon Delirious Ask FaceBook

Pages: [1]   Go Down
  Print  
Author Topic: how to model intensity and blurring of image in Ejs ?  (Read 9298 times)
0 Members and 1 Guest are viewing this topic. Click to toggle author information(expand message area).
lookang
Hero Member
*****
Offline Offline

Posts: 1784


http://weelookang.blogspot.com


WWW
«
Embed this message
on: January 01, 2010, 07:06:09 pm »

how to model intensity and blurring of image in Ejs ?
to see the real image we need a screen. yet i notice most simulation dun include a screen. I request that someone create an simulation that is something like the one in this thread but add a screen that is adjustable so we can see how does adjusting the screen affect the image. thx Cool Cheesy Smiley Wink Tongue Kiss

I noticed in http://www.yenka.com/en/Yenka_Light_and_Sound/ there is a similar concept for reference viewable in the image there.
http://www.yenka.com/en/Yenka_Light_and_Sound/attachments/y-t2-1-1.gif
Thanks!

I have been testing on this, i managed to model the size X and Y but what transformation do i do to make picture blur ?

I have not seen any blurring effect on Ejs applets, can it be done?
anyway i been looking at http://www.huxtable.com/ip/blurring.html
seems like i need View GaussianFilter.java


* image2.png (206.92 KB, 1054x830 - viewed 332 times.)

*** There are 1 more attached files. You need to login to acces it!
« Last Edit: January 01, 2010, 08:50:15 pm by lookang » Logged
Fu-Kwun Hwang
Administrator
Hero Member
*****
Offline Offline

Posts: 3080



WWW
«
Embed this message
Reply #1 on: January 01, 2010, 11:08:43 pm » posted from:Taipei,T\'ai-pei,Taiwan

I do not think the current version of EJS GUI can do the effect you need.
But you can ask Paco to add it as part of EJS image property. Just provide him the source code and he should be able to implement it soon (if he think it is necessary).
 
Logged
lookang
Hero Member
*****
Offline Offline

Posts: 1784


http://weelookang.blogspot.com


WWW
«
Embed this message
Reply #2 on: January 05, 2010, 09:46:52 pm »

i have been looking at the codes by Paco.

Code:
public void setImage () {
  java.awt.image.BufferedImage myImage = org.opensourcephysics.tools.ResourceLoader.getBufferedImage("./tmp3D/TEXTURES/fixed_stars.jpg");
  _view.image.setImage(myImage);
}

public void blurImage() {
   float[] matrix = {
   0.111f, 0.111f, 0.111f,
   0.111f, 0.111f, 0.111f,
   0.111f, 0.111f, 0.111f,
   };

  java.awt.image.BufferedImage sourceImage = org.opensourcephysics.tools.ResourceLoader.getBufferedImage("./tmp3D/TEXTURES/fixed_stars.jpg");
  java.awt.image.BufferedImage destImage = new java.awt.image.BufferedImage(sourceImage.getWidth(), sourceImage.getHeight(), sourceImage.getType());
  java.awt.image.BufferedImageOp op = new java.awt.image.ConvolveOp( new java.awt.image.Kernel(3, 3, matrix) );
  op.filter(sourceImage, destImage);
  _view.image.setImage(destImage);
}

but i have little clue have to add a variable to make the blur depend on a variable control by a slider.

then i go look at
http://www.huxtable.com/ip/blurring.html http://www.huxtable.com/ip/ConvolveFilter.java

so i try to add the variable as the number 400 by instead i used numbertodivide

is the code correct?

public void setImage () {
  java.awt.image.BufferedImage myImage = org.opensourcephysics.tools.ResourceLoader.getBufferedImage("./tmp3D/TEXTURES/fixed_stars.jpg");
  _view.image.setImage(myImage);
}
integer rows;
integer columns;
numbertodivide = rows*columns;

public void blurImage(integer numbertodivide) {

float[] matrix = new float[numbertodivide];
   for (int i = 0; i < numbertodivide; i++)
      matrix = 1.0f/numbertodivide*1.0f;
      
// BufferedImageOp op = new ConvolveOp( new Kernel(20, 20, matrix), ConvolveOp.EDGE_NO_OP, null );
//   blurredImage = op.filter(sourceImage, destImage);
 java.awt.image.BufferedImage sourceImage = org.opensourcephysics.tools.ResourceLoader.getBufferedImage("./tmp3D/TEXTURES/fixed_stars.jpg");
  java.awt.image.BufferedImage destImage = new java.awt.image.BufferedImage(sourceImage.getWidth(), sourceImage.getHeight(), sourceImage.getType());
  java.awt.image.BufferedImageOp op = new java.awt.image.ConvolveOp( new java.awt.image.Kernel(rows, columns, matrix) );
  op.filter(sourceImage, destImage);
  _view.image.setImage(destImage);
}

the error message is
C:\Users\160\Desktop\EJS_4.2_091119\EJS_4.2\workspace\output\users\sgeducation\lookang\ejs_ImageTest\ImageTest.java:167: expected
  numbertodivide = rows*columns; // > Custom.Lib Page:7
   ^
1 error
Compilation produced an error!

any tips why error?
First attachment is orginal from Paco
Second is my working  Grin


*** There are 2 more attached files. You need to login to acces it!
« Last Edit: January 05, 2010, 10:14:32 pm by lookang » Logged
Fu-Kwun Hwang
Administrator
Hero Member
*****
Offline Offline

Posts: 3080



WWW
«
Embed this message
Reply #3 on: January 05, 2010, 10:50:49 pm » posted from:Taipei,T\'ai-pei,Taiwan

You should have define
public void blurImage(int numbertodivide)
instead of public void blurImage(intwger numbertodivide)

and you do not need
Code:
integer rows;
integer columns;
numbertodivide = rows*columns;
in the lib panel.

There are other errors: for example you call it with blurImage(); without any parameter.

I corrected several error in your code (see attached file).
However, you are not consistant. for exmaple:yo have
Code:
  java.awt.image.BufferedImageOp op = new java.awt.image.ConvolveOp( new java.awt.image.Kernel(rows, columns, matrix) );
which involve rows and columns. However, it is not related to numbertodivide in your code, and the setting of matrix.

You should modify the following code to make it more consistant.
Code:
float[] matrix = new float[numbertodivide];
for (int i = 0; i < numbertodivide; i++)
matrix[i] = 1.0f/numbertodivide*1.0f;




*** There are 1 more attached files. You need to login to acces it!
Logged
lookang
Hero Member
*****
Offline Offline

Posts: 1784


http://weelookang.blogspot.com


WWW
«
Embed this message
Reply #4 on: January 06, 2010, 11:08:30 pm » posted from:Singapore,,Singapore

thanks! i am working on it!


*** There are 1 more attached files. You need to login to acces it!
Logged
lookang
Hero Member
*****
Offline Offline

Posts: 1784


http://weelookang.blogspot.com


WWW
«
Embed this message
Reply #5 on: January 26, 2010, 02:58:10 pm » posted from:SINGAPORE,SINGAPORE,SINGAPORE

i think the codes i modified to
Code:
float[] matrix = new float[numbertodivide];
for (int i = 0; i < numbertodivide; i++)
matrix[i] = 1.0f/numbertodivide*1.0f;
it does not blur.

i changed the picture, it seems to only dim ( reduce the intensity ).

i suspect the code in wrong "matrix = 1.0f/numbertodivide*1.0f;" some how the "f" which i think means float is not working correctly when i change the codes from

original code from http://www.huxtable.com/ip/blurring.html
Code:
float[] matrix = new float[400];
for (int i = 0; i < 400; i++)
matrix[i] = 1.0f/400.0f;

thanks for your help!

Embed a running copy of this simulation

Embed a running copy link(show simulation in a popuped window)
Full screen applet or Problem viewing java?Add http://www.phy.ntnu.edu.tw/ to exception site list
Press the Alt key and the left mouse button to drag the applet off the browser and onto the desktop. This work is licensed under a Creative Commons Attribution 2.5 Taiwan License
  • Please feel free to post your ideas about how to use the simulation for better teaching and learning.
  • Post questions to be asked to help students to think, to explore.
  • Upload worksheets as attached files to share with more users.
Let's work together. We can help more users understand physics conceptually and enjoy the fun of learning physics!


*** There are 1 more attached files. You need to login to acces it!
« Last Edit: January 26, 2010, 03:00:51 pm by lookang » Logged
Pages: [1]   Go Up
  Print  
Brevity is the Soul of wit. ..."Shakespeare (154-1616, English dramatist and poet) "
 
Jump to:  


Related Topics
Subject Started by Replies Views Last post
will the image remain there
Optics
anmolbuber 1 8879 Last post March 17, 2007, 09:07:53 pm
by vvelemir
It is fun to play with prism. (light trace and intensity due to refraction)
Optics
Fu-Kwun Hwang 2 29126 Last post July 25, 2012, 08:23:38 am
by Fu-Kwun Hwang
using fiber optics for light path to an image to an area array image sensor
Optics
jackspar 0 5996 Last post February 17, 2009, 04:32:03 pm
by jackspar
Link EJS GUI properties to model variables (image:width/height/angle)
Examples for beginner who want to learn EJS
Fu-Kwun Hwang 0 7210 Last post March 29, 2009, 01:53:08 pm
by Fu-Kwun Hwang
Intensity variation for reflected/refracted light
optics
ahmedelshfie 0 3502 Last post May 23, 2010, 10:39:37 pm
by ahmedelshfie
Powered by MySQL Powered by PHP Powered by SMF 1.1.13 | SMF © 2006-2011, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 0.063 seconds with 22 queries.since 2011/06/15