How To Get Pixel Values Of Image And Store It Into Array

Nov 13, 2014

So i wanted to try something new like find an image within an image. So for my "find" method I would like to take an image and use it to scan and compare sum of absolute differences with the bigger image. So that the smallest SAD would be the exact image that I am using to scan. What I am thinking is to put each pixel value of both images into two separate arrays and compare them via Math.abs(image1[i][j]-image2[i][j]); . My only problem is that I do not know how to put each pixel value into an array.

Also, If I only want to compare just the green in the picture. I saw that the Pixel class has a getGreen(); method. If I want to find the SAD of the green, would Math.abs(image1.getGreen()-image2.getGreen()); work? I was planning to have 2 nested loops running through each column and row for each image and just find the SAD of the green value.

View Replies


ADVERTISEMENT

Store Pixels Values Currently On Screen And Compare Them To Values On The First Frame?

Aug 29, 2014

I need a way to store the pixels values currently on the screen and compare them to the values on the first frame. Right now I'm using glreadpixels as follows:

currentBuffer= BufferTools.reserveByteData(mapSize);
glReadPixels(mapStartX, mapStartY, mapWidth, mapHeight, GL_BLUE, GL_UNSIGNED_BYTE, currentBuffer);
for (int i = 0; i < mapSize; i++) {
if (currentBuffer.get(i) != baseBuffer.get(i)) {
//Do nothing
continue;
}
//Do something
}

This works perfectly fine but turns out to be a real bottleneck, dropping the fps to a third of what it was. Is there any quicker way? All I'm after is speed, I don't even need to show it on the screen if the comparison is made "behind the scene".

View Replies View Related

File Reading Values To Draw Image (java Graphics DrawString / ArrayList / Array)

Sep 13, 2014

//compiler error I'm receiving
J:CS3Student Folder Review Lab #2APlusImage.java:41: error: cannot find symbol
xcor.add(read.nexInt());

[Code].....

View Replies View Related

Converting 1x1 Pixel To 3x3 Pixel

Nov 17, 2014

this code that I've constructed?

//Setting the size of the graphics window
final int WINDOW_DIMENSION = 200;
EasyGraphics generate = new EasyGraphics(WINDOW_DIMENSION,WINDOW_DIMENSION);
 
[Code].....

What I would like to do is to convert the 200x200 picture to a 600x600 graphic window. Currently, my code is structured in such a way that it zooms into the 200x200 display by a factor of 3.

View Replies View Related

Store The Image Into Database In Netbeans?

Jan 28, 2014

I have a image package consisting of images and they are displayed in a jlabel.I used the code below for that

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
Image im=new ImageIcon(this.getClass()
.getResource("/images/" + imageNames[index])).getImage();
ImageIcon iconLogo = new ImageIcon(im);
jLabel5.setIcon(iconLogo);
}

Now I want to store the image displayed in the jlabel into the database(oracle).From the above code I dont know how to get the absolute path of the images.

View Replies View Related

JSP :: Store A File / Image Into Oracle Database And Display On Browser?

Nov 2, 2014

I want to store an image/file into oracle database using jsp.

I have written code to store data when am running in my machine it is working fine, but not working in server throwing an error saying that "The system cannot find the file specified."

I am attaching the code what am written.

View Replies View Related

Store Celsius And Fahrenheit Values Equal To One Another Using Loop

Sep 29, 2014

Write java program using table that stores celsius and farenheit values that are equal to one another using a loop. use C 0-20 and convert to farenheit.

I have to use doubles for Celsius and Fahrenheit and in the formula. I get a runtime error with the following displayed:

I will display a table of temperatures in their Celsius and Farenheit equivalents.

celsiusfarenheit

import java.util.*;
import java.lang.*;
import java.io.*;
class TemperatureConversion {
public static void main (String[] args) throws java.lang.Exception {
double celsius;// Temperature in degrees Celsius minimum
double farenheit;// Temperature in degrees Fahrenheit

[Code] ....

View Replies View Related

Generate 10 Random Integers / Store In Array And Then Calling A Method To Display Array

Nov 8, 2014

So I need to generate 10 random integers in the range 1-20 but i have to store them in an array called numbers. Then I have to call a method called displayArray which displays the contents of the array and for the assignment i have to use a for loop to traverse the array. The method header for the displayArray method is:

public static void displayArray(int[] array)

This is what I have done
 
public class RandomIntegers {
 static int numbers = 0;
public static void displayArray(int[] array) {
System.out.println(numbers + "Numbers Generated");

[Code] .....

View Replies View Related

How To Store 2 Related Elements Using 2x2 Array

Jul 16, 2014

I have the simple table below:

currency amount
€ 2.0
$ 4.0
£ 5.0

How could I store the currency and amount in an array? A 2x2 array would do this but how to store them and retrieve them is the challenge. For example, I have a method that asks the user for two inputs, the currency and the amount and using the array as a chat table where I could map the currency to the the currency input entered by the user, I could do some calculations with the amount entered by the user. how I could represent the 2x2 array?

View Replies View Related

Program That Use Array To Store 10 Numbers

Oct 16, 2014

i'm trying to write a program that uses an array to store 10 numbers. The numbers should be randomly generated ( Math.random() ), and they should be between 1 and 100 ( 1 and 100 inclusive ). The program should produce an output like the one below:

Element 1 = 23 ( Odd )
Element 2 = 15 ( Odd )
Element 3 = 32 ( Even )
Element 4 - 10 ( Even )
Element 5 - 99 ( Odd )
Element 6 - 1 ( Odd )

[Code]...

I have written code for this but its only showing me 0's after first number can you check whats wrong with my code. my code is.

class even/odd{
public static void main(String[]args){
int y=0;
int z=0;
int[] array= new int[11];
for(int x=1; x <array.length ; x++){
array[x]= (int) (Math.random()* 100);
 
[Code]...

View Replies View Related

How To Store A File In Hashmap Or 2D Array

Sep 25, 2014

I have a file called statecapitals.txt that is read in, I want to store it in either a 2d array or hashmap and select a random state then Ask the user for the name of the capital. Then I want to Let them know if they are correct or not and have a choice to play as many times as they like. When they no longer want to play,I want to let them know how many they got correct and how many incorrect. I am not sure which would be better a hash map or 2d array and dont know where to start with each.

here is what the text file looks like:

Alabama - Montgomery
Alaska - Juneau
Arizona - Phoenix
Arkansas - Little Rock
California - Sacramento
Colorado - Denver

[code]....

View Replies View Related

Store Numbers In Array Then Sort

Feb 19, 2014

Code below. I am not sure if my logic is correct. I want to prompt a user to enter registration numbers from 100 to 1000, store the numbers in an array then sort them.

import java.util.Scanner;
class regnumber
{
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
System.out.println("registration number ", 100,1000);

[Code] ....

View Replies View Related

Some Pixel Manipulation

Oct 25, 2014

I currently have an on going project of making a gameengine and am currently doing a lighting engine. How to create simple algorithm of explain to me the concepts of creating a algorthm to do a task, like explain how to get the hue saturation and brightness. This preferably needs to be done in java for me to copy the code but as long as i have a concept to go by I could probably translate the code over so it's not to much of a problem.

View Replies View Related

Read ASCII Art Map And Store Information In 2D Array

Feb 12, 2014

I've written some code to do this, but it's not working as I expect. This is what the ASCII map looks like:

###################
#.................#
#......G........E.#
#.................#
#..E..............#
#..........G......#
#.................#
#.................#
###################

Here's how I've tried to store the information in a 2D array:

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.Arrays;
 public class Map {
 public void importMap() throws IOException{
BufferedReader br = new BufferedReader(new FileReader("map.txt"));
String line;

[Code] ....

But it's not printing out what I'm expecting. It's printing out:

[[#, #, #, #, #, #, #, #, #], [#, #, #, #, #, #, #, #, #], [#, #, #, #, #, #, #, #, #], [#, #, #, #, #, #, #, #, #], [#, #, #, #, #, #, #, #, #], [#, #, #, #, #, #, #, #, #], [#, #, #, #, #, #, #, #, #], [#, #, #, #, #, #, #, #, #], [

What is printed is much larger than what I've copy and pasted but I can't post it all here.

The error I get is:

Exception in thread "main" java.io.IOException: Stream closed
at java.io.BufferedReader.ensureOpen(Unknown Source)
at java.io.BufferedReader.readLine(Unknown Source)
at java.io.BufferedReader.readLine(Unknown Source)
at Map.importMap(Map.java:26)
at Map.main(Map.java:44)

View Replies View Related

How To Copy 5x5 Array Into 6x6 And Store New Value To Take Up Sixth Position

May 5, 2015

I want to take my 5x5 array that reads data from a file, add the rows and columns, then print out a new 6x6 array with those values. Here is my code that shows I understand everything except this.

import java.io.*;
import java.util.*;
public class prog470cAddingRandC
{
public static void main (String [] args)
{
//read the file
Scanner inFile=null;
 
[Code] ....

I was told in a previous question to make the starting array 6x6 but that is not working. How do I take sum1 and sum2 and store that along with the values of the old array and print it?

View Replies View Related

Create Country Object And Store In Array

Oct 12, 2014

Write a program that prompts the user for information about some countries, creates an object for each country, and then stores the objects in an array. After the user has entered information about all the countries, your program should print out which countries in the list have the smallest and largest area and population density. Assume the user will enter information about at least one country but that the program will not have to store more than ten countries in the array. The user will indicate that they are done entering countries by typing "DONE" for a country name. Here is an example of what your program must look like when it is executed (user input is shown bold)

Please enter the name of a country: United States
Enter the area in square km and population of United States: 9827000 310000000
Please enter the name of a country: Mexico
Enter the area in square km and population of Mexico: 1973000 122300000
Please enter the name of a country: Canada
Enter the area in square km and population of Canada: 9985000 35160000
Please enter the name of a country: Liberia
Enter the area in square km and population of Liberia: 111370 4294000
Please enter the name of a country: DONE

Liberia has the smallest area at 111370 square km.
Canada has the largest area at 9985000 square km.
Canada has the smallest population density at 3.521282 people per square km.
Mexico has the largest population density at 61.986822 people per square km.

I don't know, I'm really confused with this Java program. I don't know how to do the main part of the program where the user inputs, array, and the output.

// Access the Scanner and ArrayList class by importing the java.util package.
import java.util.Scanner;

/** Project - A Country Object
* The purpose of this program is for the user to enter some information at most 10 countries. After the user has entered information about all the countries, the program should print out which countries in the list have the smallest and largest area and population density.
*/

public class Country
{
private String countryName;
private int theArea;
private int thePopulation;
public Country(String countryName, int thePopulation, int theArea)

[Code] ....

View Replies View Related

Fibonacci Application - Store Its Sequence In Array

Mar 12, 2014

Modify the Improved Fibonacci application to store its sequence in an array. Do this by creating a new class to hold both the value and a boolean value that says whether the value is even, and then having an array of object references to objects of that class.

Did I just need to declaring the variable in other class (for boolean value and the value itself) or else ?

Here is the code for ImprovedFibonacci.java

Java Code:

class ImprovedFibonacci {
static final int MAX_INDEX = 9;
/**
* Print out the first few Fibonacci numbers,
* marking evens with a '*'
*/
public static void main(String[] args) {
int lo = 1;
int hi = 1;
String mark;

[Code] ....

View Replies View Related

Another Java Pixel Manipulation

Nov 21, 2014

I have a jpeg that I need to print a border around. My plan was to take the jpeg and throw it on top of a second image that is a few pixels bigger in each direction. Currently, my code prints the image with a white border on the right and bottom sides. Is there a way to print the border on all sides, and maybe even make it a more distinct color? I am not allowed to use graphics. I can only manipulate pixels. Here is the basis of my code.

public class MyArt
{
private Picture image;
/**
* Create an Art object using the jpg or bmp at the indicated location
*/
public MyArt(String filename)
{
image = new Picture(filename);

[code]....

View Replies View Related

BufferedImage Or Pixel Arrays

Jun 30, 2014

I am making a 2d game engine and i was wonder is it better to use BufferedImages and subImages to store/render sprites from sprite sheets or use BufferedImages and store it in a pixel array and then manipulate the pixel array to do what you want.

Basically is loading in BufferedImage and getting the tile of the sprite sheet with subImages better than loading in a BufferedImage and then putting the data in a pixel array and making a new array with the part of the BufferedImage you want.what i have been told the BufferedImage and subImage use more of the graphics card and the pixel array method uses more of the processor.

View Replies View Related

Open A File And Store Contents Into A Two Dimensional Array

Feb 11, 2014

So I am trying to open a file and store the contents into a two dimensional array. I seem to have no problem using this same basic code to read the file and output it. But when I try to change it so that all the data is stored into the array, it does not work.

Java Code:

public void convertFile()
{
String filePath = ("C:UsersBradDownloadsFB1.csv");
String [][] rowCol = new String [429][6];
try
{
BufferedReader br = new BufferedReader(new FileReader(filePath));
StringTokenizer st = null;
System.out.println("Your file is being converted to an array. This may take several minutes.");

[code]....

View Replies View Related

Store Data From A File Into Array Of Type Product?

Mar 17, 2015

public class InputFileData {
/**
* @param inputFile a file giving the data for an electronic
* equipment supplier’s product range
* @return an array of product details
* @throws IOException
*/
public static Product [] readProductDataFile(File inputFile)
throws IOException{
// YOUR CODE HERE
}

This code is meant to be used to read a text file and store the data in an array of type Product[]. I know how to read in a text file and have it sort it into an array, but I've never seen code laid out in this fashion before (specifically "public static Product[]", and I'm unsure how to work with "(File inputfile)". I've looked all over the place but can't find any examples of anything like this.

Also, the code given cannot be changed, as it's that code I have to work with.

I still don't understand how to use it as a whole. For example, do I read the file in the main and have this method read that in and output to the Product class? Do I read the file in this method? I can't work out how to make this work when I have to use this method.

View Replies View Related

Store String Input In Array And Print In Reverse Order

Apr 5, 2014

I have a college question ask me to write a class StringRevert which does the following:

-prompting user for an interger n
-creating an array of n string
-repeatedly read character string from user input and store them in the array until end of array is reached or user input -quit(quit should not saved in array)
-print the string from array in reverse order, from last enter to first enter.
-assume user always supplie correct input

This is what I've done so far but how to get it working.

import java.util.Scanner;
public class StringRevert {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("enter value of n: ");
int n1 = in.nextInt();
String[] n = new String[n1];

[Code] ....

View Replies View Related

Pass Objects From 3 Different Methods At Random To Different Class And Store In Array?

Jun 8, 2014

in my progrm there are three diff array of objects...namely garments..gadgets and home app...now one who buys from each of these sections will have to make a bill at last...when he choses to make the bill he will be shown the list of products he bought and their details (like price...brand...etc)...so i thought that while he orders each product(which is done in a previous method called purchase()...)....(each product is stored as an object in there diif arrays namely garments...gadgets ...appliances)....each of those object will be copied in a new array in a diif class...then that array print will give me the desired result...

is this approach correct...?and if its correct then how can i pull out a specific obj frm a stored array of object and then save it in a new array....?

View Replies View Related

Program To Store Total Rainfall For Each Of 12 Months Into Array Of Doubles

Oct 26, 2014

"Create a project called RainFall and a class nameD RainFall. Write a program that stores the total rainfall for each of 12 months into an array of doubles. The program should display total rainfall for the year, the average monthly rainfall, the month with the most rain and the month with the least rain. When outputting the month with the most and least rain, output the name of the month. This is what I have so far.

Scanner keyboard = new Scanner(System.in);
double averageMonthly;
double mostRain;
double leastRain;
int months;
double monthlyRain = 0;
double totalRain = 0;

[Code] ....

View Replies View Related

Get Data From Config File And Store In Array Without Using Split Method

May 8, 2014

How i can get the data from a file, for a key that have multiple values without using split method and i want to store that data in an array

file name:"new.txt"[contains below data]
Name=google.com, yahoo.com,facebook.com
Attachment=abc1,abc2,abc3

I am successfully able to do this using following code

Properties props = new Properties();
String configFilePath = (Cjava_confignew.txt);
props.load(new FileReader(configFilePath));
String TestName = props.getProperty(Name);
String test[] = TestName.split(,);

Now i just want to store the values for key "Name" in array without using TestName.split(,); but i am not able to do this.

I have also used .yml file to avoid this but did not succeed, some way to do this

file name test.yml

Name
-google.com
-yahoo.com
-facebook.com

Attachment
-abc1
-abc2
-abc3

i want to store multiple values for single key(Name) within the array

View Replies View Related

Read Characters From Txt File / Store Them Into 2D Array And Print Information

Oct 10, 2014

The point of this program is to read characters from a txt file and store them into a 2D array. After this has been accomplished, the information is to be printed in the same manner it is read from in the txt file.

Here is the code I have so far:

import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
public class Main
{
public static void main(String[] args) throws FileNotFoundException

[Code] ....

And this is the error I am receiving when trying to accomplish the goal of the project:

Exception in thread "main" java.lang.NumberFormatException: For input string: "############"
at java.lang.NumberFormatException.forInputString(Unk nown Source)
at java.lang.Integer.parseInt(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at Maze.<init>(Maze.java:15)
at Main.main(Main.java:20)

What's going on here and how I can correct this?? The information I am trying to store in a 2D array and then print is this:

############
#.#........#
#.#.######.#
#.#....#...#
#.###.*#.#.#
#...####.#.#
#.#.#..#.#.#
#.#.#.##.#.#
#o#......#.#

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved