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
ADVERTISEMENT
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
Nov 20, 2014
I am working on a project using pictures and am having some trouble. My assignment is to take a jpeg, and reflect it(over an imaginary x-axis so to speak). As this is my first time working with images, I am very lost. My approach was to take "pixel 0" and have it swap places with "pixel max". Theoretically, I believe I would only need to do this for the first 50% of the pixels, as each flip works on 2 opposite pixels. With my code thus far (the reflect() method), I print the left half of the image. Note: I must use pixel manipulation. I cannot use graphics.
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
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
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
Mar 21, 2015
I'm working on a project based on Roger Alsing's Mona Lisa evolution.
My problem seems to be that when I compare the RGB values of the target image and the randomly generated image, I don't get a representative result of how "close" the two images are.
I load the target image (a 24-bit bitmap) using:
img = ImageIO.read(new File(filePath));
I draw onto a BufferedImage with:
for(int i = 0; i < numPolys*12; i += 12){
p[(int)(i/12)].addPoint(gene[i], gene[i+1]);
p[(int)(i/12)].addPoint(gene[i+2], gene[i+3]);
p[(int)(i/12)].addPoint(gene[i+4], gene[i+5]);
p[(int)(i/12)].addPoint(gene[i+6], gene[i+7]);
Color mycol = new Color(gene[i+8], gene[i+9], gene[i+10], gene[i+11]);
gf.setColor(mycol);
gf.fillPolygon(p[(int)(i/12)]);
}
And I compare the BufferedImage with the target image using:
for(int x = 0; x < inGene.x; ++x){
for(int y = 0; y < inGene.y; ++y){
Color mycol1 = new Color(exp.getRGB(x, y));
Color mycol2 = new Color(inImage.getRGB(x, y));
int delta = mycol1.getRed() - mycol2.getRed();
score += (delta * delta);
delta = mycol1.getGreen() - mycol2.getGreen();
score += (delta * delta);
delta = mycol1.getBlue() - mycol2.getBlue();
score += (delta * delta);
}
}
My problem is that my code runs to a certain point, where it seems no matter what happens to the image, it doesn't seem to get any closer to the target image.
View Replies
View Related
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
View Related
Sep 15, 2014
I'm currently starting my thesis where my Project will involve creating a diff and merge tool for simulink slx files. These are built using several xml files, a png and sometimes some other data files. One can get to these files by changing the file extension to zip.
I am a bit troubled by this since I want to be able to handle all these files simultaneously and hence need to do this automatically when choosing the slx file.
View Replies
View Related
Mar 9, 2014
"Object contains data and code to manipulate that data."
Is the statement right ?? as far as i know object only contains copy of instance variables.
View Replies
View Related
Apr 17, 2014
I have a string and i need to do some manipulation with that. I have tried couple of things but not sure if those are feasible or not. Here is the situation:
uid=aa,bb,ou=people,cn=administrativeldap,cn=punit.punit.a-12-m020.20,o=ttt
I want the value of uid from this string, actually it's user id.
This particular string i want :: aa,bb
Things which i have tried:
I was trying it in this way string start with uid and ends with ou, but in this case user name itself can have ou, so in that case it breaks. Another approach i was thinking of is splitting the string by = which gives me aa'',bb,ou at first position and then i will again split this string to remove ,ou. but i am not sure if this approach is good or not?
View Replies
View Related
Apr 14, 2014
I need to create an java 2D application for the manipulation of image. I saw the JAI library but it can not install it properly, I also copied the jar but I can not find the solution. How can I do? there is a replacement for JAI? what other libraries can I use?
View Replies
View Related
Jan 23, 2015
I have to write a program that asks the user to enter the name of their favorite city and use string variable to store the input. The program should display the following:
-The number of characters in the city name
-The name of the city in all uppercase letters
-The name of the city in all lowercase letters
-The first character in the name of the city
However, I can't seem to get past the following errors;
Programming Challenge #12.java:37: error: variable cityFirstChar is already defined in method main(String[])
char cityFirstChar = city.charAt(0);
^
8 errors[CODE
----jGRASP wedge2: exit code for process is 1.
----jGRASP: operation complete.
[/CODE]
My code is as follows:
import java.util.Scanner;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
[code]....
View Replies
View Related
Sep 11, 2014
I am suppose to create a rectangle and I have created two classes; Rectangle.java and RectangleTester.Java.
So far my code for the class Rentangle.java is:
package edu.sbcc.hw2;
public class Rectangle {
private int width = 25;
private int height = 25;
public rectangle(int xcoord, int ycoord, int thewidth, int theheight) {
this.width = width;
this.height = height;
}
public int getWidth() {
return width;
So for my assignment I need two instance variables for height and width for which I have, but it says in the assignment I need methods (settings and getters /mutators and accessors that allow manipulation of my instance variables which is a little confusing. Do I put these methods on Rectangle.java or RectangleTester.java.
The same goes for the calculateArea, where am I suppose to put this?
View Replies
View Related
Feb 18, 2014
I do have a quick question about string manipulation. You see I've been given a simple exercise that involves asking the user to input a number between 1,000 and 999,999 and displaying the result. Simple enough, but the caveat is that if the user keys in the comma, say 24,000 instead of 24000 for example, the program is not to display the comma. I don't see how to do this without an 'if' statement. The book says the 'if' is not necessary but does offer this hint: "Read the input as a string. Measure the length of the string. Suppose it contains n characters. Then extract the substrings consisting of the first n-4 characters and the last three characters."
What good is n-4 going to do if the string's lengths varies?
Here's what I have written thus far:
import java.util.Scanner;
public class P13
{
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
System.out.print("Please enter a number between 1,000 and 999,999: ");
[Code] .....
View Replies
View Related
Sep 29, 2014
I am attempting to use JLists to complete a program that models how operating systems manage processes. A quick synopsis of what it is supposed to do. Each process is to have a priority level (I chose to do 1 -3 with 3 being the most important) and there are supposed to be three lists. One for ready processes, blocked processes, and a running process.
My issues:
1) when I block a process it does indeed switch lists but when it is copied into the blocked list it pulls the element number instead of what the actual process number is. For ex: Say the ready list has 5 processes / I delete 2 / Leaving process 1, 2, 5. When I block 5, it gets registered in the blocked list as process 2.
2) I can't figure out how to give a label to each of my scroll panels (JLists) to signify which box is ready / blocked / and running
3) My switch button - I have commented in what I need to do but don't know how I am going to do it.
Below are my files:
Main
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Queue;
import javax.swing.JFrame;
import javax.swing.JTextArea;
public class PQueue {
public static void main(String[] args) throws InterruptedException {
[Code] ....
View Replies
View Related
Oct 1, 2014
I'm playing with vectors for the first time... What I'm trying to do is to allow a user to input one or more integers and store them in a vector for manipulation later on in the program... Here's the portion of the program I'm working with:
Java Code:
package com.itse2317;
import java.util.*;
public class VectorTest
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
[code]...
My question is this: Is there any way to move from inputting integers to printing them, without entering a non-integer (for example, hitting enter)? I looked at the API for the Vector class, and either I'm not thinking about the problem the right way to be able to find an answer, or it's just not there.
View Replies
View Related
Apr 7, 2014
Sir, I'am new to Swing Programming. I have to create an application where an image is displayed on one Label. The same image has to be split in parts and stored in database pert wise. Later the user has to retrieve the entire image by viewing a small part of the image. I have already displayed the full image on the Label, now i don't know how to split the image and store it part wise in the database.
View Replies
View Related