Swing/AWT/SWT :: Convolution And Gray Scale Filter
Jun 23, 2014
I implemented the gray scale filter and the convolution filter . If I apply before the grayscale filter convolution and then I can not see the picture, I see pretty much the JPanel that should contain the image. The two filters separately functioning correctly
Code filter grey scale
public BufferedImage greyScale(BufferedImage originalImage) {
BufferedImage destImg = new BufferedImage(originalImage.getWidth(), originalImage.getHeight(), BufferedImage.TYPE_INT_ARGB);
int alpha, red, green, blue;
for (int x = 0; x < originalImage.getWidth(); x++) {
for (int y = 0; y < originalImage.getHeight(); y++) {
int pixel = originalImage.getRGB(x, y);
I am trying to make a game with an image on it, and I have one class that gets the image and the other is the game. When I run the program, it just shows my image on a gray JFrame. This leads me to think the image might be covering my whole game, which is weird because it is a mostly transparent image. I have tried resizing it and everything but I don't know what to do..
Not necessarily Java related, more a general programming issue I have come a long and I am currently using java to mock up a project that will eventually get moved over to C++.
I am trying to implement FFT Convolution into a java project and have things partially working, I do not know if it is a coding issue, logic issue or if I simply know nothing of FFT and convolution.
For starters I got an FFT library that I do have working, if I create a small array pass it into the forward FFT, do a little bit of bit manipulation (converting a complex array of size n*2 into a re[] and im[] of size n), run the inverse FFT and do the same bit manipulation again I get back where I started.
However if I take two arrays, a Dirac Delta function (an array with a 1 followed by zeros for the rest of the array) and a stepping kernel (ex. {1, 2, 3, 4 etc}), I would expect to get the forward FFT of both arrays, bit manipulation, multiply them together, Inverse FFT, and bit manipulate again and the result would be the kernel. I have not had such luck.
This is the gist of the program:
// bit manipulation, converts complex array to two re and im arrays public void bitTwiddle(double [] real, double [] real2, double [] imaginary){
for (int idx = 0; idx < (N * 2); idx++){ realCopy[idx] = real [idx];
[Code] ....
This is the result:
Quote ===================================================================== Dirac Delta In Time Domain: Real:1.000.000.000.00 Imag:0.000.000.000.00 ===================================================================== Dirac Delta Frequency Domain Real:0.500.500.500.50 Imag:0.000.000.000.00 ===================================================================== Kernel In Time Domain Real:1.002.003.004.00 Imag:0.000.000.000.00 ===================================================================== Kernel In Frequency Domain Real:5.00-1.00-1.00-1.00 Imag:0.00-1.000.001.00 ===================================================================== Result: Dirac Delta x Kernel Real:2.50-0.50-0.50-0.50 Imag:0.00-0.000.000.00 ===================================================================== Result In Time Domain Real:0.501.501.501.50 Imag:0.000.000.00-0.00
I am developing in Android Studio and I made a simple background, the actual resolution of the image is 1440 by 2560. I made it that resolution so, 1, it is easier to scale down than up, and 2, in android studio i use a nexus 6 as my preview. When I plugged in my gs4, not a 1440 by 2560 display, the background wouldn't show up when I ran it on my gs4(galaxy s 4). How do i get my background to scale and display on any display size.
I'm having trouble creating a highly efficient algorithm for counting within a custom scale. This problem applies to futures trading, specifically treasuries contracts.
One specific treasury contract has 32 units before rolling over to the next whole number. So, the price scale looks something like this ...
If I pick a number (price) at random, let's say 1 28, and I want to add 8 units to that value, I should end up with 2 4. I can do this using brute force, calculating remainders, etc, etc....
I'm trying to figure out how to print the Major Scale of any give note in music. It works as follows:
There are 12 notes and each note is assigned a number
C = 0, C# = 1, D = 2, D# = 3, E = 4, F = 5, F# = 6, G = 7, G# = 8, A = 9, Bb = 10, B = 11.
After picking a random note, say F, the idea is to add the following sequence to move through the scale:
0, +2, +2, +1, +2, +2, +2, +1.
So, with F being 5, we move through the scale as 5, 7, 9, 10, 0, 2, 4, 5.
The theory is unimportant but, as you can see, the sequence loops back on itself, rather than continue past 11. This is where I'm stuck, though. I'm not clear on how to loop my numbers around in code. I'll show my attempt here:
public static void main(String[] scale) { majorScaleOf(0); //0 represents C!! majorScaleOf(5); //5 represents F!! majorScaleOf(10); //Bb = B flat!!
[Code] ....
For the sake of simplicity I haven't shown the entire script of 'if' statements, but you get the idea.
The print out reads as:
0, 2, 4 (For C) 5, 7, 9 (For F) 10 (For Bb)
The last line demonstrates the problem, as I need it read as 10, 0, 2.
I've tried different approaches, but wanted to convey the basic problem with this post.
We have an application running successfully where we fetch the weight of product currently on Production Line using Java.
All the products on line belong to same order and are of same type. User at beginning enter the type of product and starts the production line.
Proposed new process: Now client want that multiple type of product can belong to same production order. i.e. on a production line different type of products can come one after other. So we should now fetch the type of product also.
The Question : what are different possibilities in which we can find the type of product. Can java fetch color of a box ? If we use scanner on line that scans the product and sends the color information to Java.
Above is just a possibility. Can there be any other parameters that Java can use to differentiate in type of product ?
Currently we are clueless. What ever are the possibilities in Java we can propose the same to client. Even if that requires additional hardware.
I am new to programming, but am working on a program that takes 6 inputted grade averages on a scale of 0.0 - 100.0 (exceptions in the case someone has exceeded the traditional 100.0 limit) and then divides it by 6 and returns the value in a dialog box. However, I want to take the values inputted and convert them to a 4.0 scale (90.0-100.0 = 4.0, 80.0-89.99 = 3.0, etc.) and then get the average of that so that I can return an average on a 4.0 scale. I have been trying to accomplish. Also, as of right now my program only prompts the user for 6 inputs, but I'd like the user to be able to input as many as he/she would like to, I am pasting the code I currently have below.
import javax.swing.JOptionPane; public class GPA_Calculation1_0 { public static void main(String[] args) { String courseOne = JOptionPane.showInputDialog("Enter numeric GPA of Course One: ");//Course one double numOne = Double.parseDouble(courseOne);
So I have scale, and you can change it, like I print out a bufferedimage read by imageio from a file, can I enlarge it by 2x, because my tiles are too small eventhough they're 16x16, should I decided to decrease my tile grid from 40 to 20, but instead change the scale by 2. Can I enlarge the image as it is put on the screen?
I've just started working on a program and i'm already having difficulties with the program. I can't get the background color to change from the basic gray color. Maybe you can tell me what i'm doing wrong.
import javax.swing.JFrame; import javax.swing.WindowConstants; import java.awt.*; import java.lang.Object; import java.awt.Color; public class FrameDemo{ public static void main(String args[]){ Toolkit toolkit = Toolkit.getDefaultToolkit ();
[Code]...
also if theres any way to shorten up what I have there, that would be great.
I have a JSF app and for some reasons i need to refresh the page on browser back button.I tried implementing the solution given in Force JSF to refresh page / view / form when back button is pressed ,the only difference is that my app runs with servlet version 2.5 so i did the mapping in web.xml as below
I am a newbie in java prgmming using netbeans IDE . I have a code Java Code:
List<String> files = service.getSecureCloudStoragePort().listFiles(); SelectFileDialog dialog = new SelectFileDialog(this.getFrame(),true,files); mh_sh_highlight_all('java');
My files value get as :
[1_car.txt@2, 5_Van.txt@6]
The 2 and 6 refers user id ... I need to show only particular user with his own id.
So need to filter the files value with that id (after @ in raw data) .. How it can do ? any method to filter the data . That data format could not be changed in any way...
I want to use a switch or if/else statement to filter out the data I don't need for the app. This is by no means anything more than a draft because java is easier to work with than android.
I just wanna confirm that when a certain processing throws an exception even when said exception happens inside doFilter, any servlet container will never proceed to the next filter right?
I have a situation to load data while JSF page loads. Also have a filter which populates user information from http request.
I was expecting the filter first to populate the user information and in the managed bean get method to verify the user information and get the data (from database). But in this case i see the managed bean get method is invoked before filter populates user information and i get null pointer exception because the user information is null.
I had to work around to get the user information from FacesContext in the managed bean get method because the user information wasn't available. Is there a way to make sure the filter is invoked first?
I have a scenario here where the JSF lifecycle is not getting invoked. I have a filter, whose responsibility is to filter only authorized requests.the code of the filter is given below
now in the else block i am filtering the unauthorized requests, and sending them back to the Login.xhtml page of the application.The problem i am encountering here is that, the images and styles associated with the page are not getting loaded, what i am thinking is that when i am using redirect or forward, the FacesServlet is not getting called, and it is directly going to Login page i.e. no Lifecyle is being called.how to Filter the requests and at same time not lose the styles?
I created filters for every column in my Jtable however, some of these columns have more than one word inside of them and my filters will only filter them based on the first word. For example if I had a first and last name in one column, it will filter the table if I enter the first name in my filter text field but it will not filter that same column if I only input the last name. What is a good regex expression to filter any word in any order?
I have a scenario here where the JSF lifecycle is not getting invoked. I have a filter, whose responsibility is to filter only authorized requests. The code of the filter is given below
Now in the else block I am filtering the unauthorized requests, and sending them back to the Login.xhtml page of the application.
The problem I am encountering here is that, the images and styles associated with the page are not getting loaded, what i am thinking is that when i am using redirect or forward, the FacesServlet is not getting called, and it is directly going to Login page i.e. no Lifecyle is being called.
Am I right on this?, if so how to Filter the requests and at same time not lose the style?
What I'm supposed to be doing is making it so the program can accept multiple filter and sort commands at one time, and each should be separated by a whitespace.I was thinking about parsing the input again, using whitespace as the delimiter, then normally progressing with each token, as though there was only one command.
However, coding this the way I'm doing it will firstly probably take hours, and secondly, it's likely not even right. I don't have any real way to determine which token contains which data from the Song objects.These are the specific requirements for this portion:A sort/filter command consists of one or more of the following options:
-year:<year(s)>
-rank:<rank(s)>
-artist:<artist>
-title:<title>
-sortBy:<field>
Any number of these options may be given, and they may be given in any order. If multiple options are specified, they will be separated by whitespace.
GazillionSongs Class (the main) Java Code: import java.util.*; import java.io.*;
I want to implement session timeout functionality ...so with web.xml file i can specify session timeout ..say 30 min.. Now with filter is it possible for me to redirect the request to login page after session is timeout say after 30 min... What are the other ways...??
Also i want to know whether timeout setting in web.xml will overweight the application server timeout ... I am using struts 1.0 and hibernate...
Looking for some simple use cases for servlet filters other than tracking requests ? I was thinking of using a filter to filter out offensive language from entered text. Would that be a good use case ?
I receive a java.lang.NumberFormatException: For input string: ""DepDelayMinutes"" error when trying to filter a list and then assign the results to a new list.
I have edited the code so it is an int that throws the exception so it isn't the presence of a string that is causing the error - java.lang.NumberFormatException: For input string: ""0914"" .
I believe the issue is because of the two sets of double quotes but I do not understand how they came about. The original dataset does not have any quotes whatsoever.