**** In java matrix(2 dimensional array) size is fixed. so I have taken the new matrix (data2) in below code snippet. new matrix (data2) dimension is equal to transpose matrix's dimension of data. And I have sent each pixel value to the new matrix(data2). ***
Pixel[][] data = theImage.getData();
Pixel[][] data2 = new
Pixel[theImage.getWidth()][theImage.getHeight()];
for(int row=theImage.getHeight()-1; row>=0;
row--){
for(int col=0;
col<theImage.getWidth(); col++){
data2[col][(theImage.getHeight()-1)-row] = data[row][col];
}
}
theImage.setData(data2);
This makes it rotate 90 degree clockwise. How would you edit it to go 90 degrees counter clockwise?
PLEASE DO NOT ANSWER IF YOU ARE NOT GOING TO ANSWER MY QUESTION! Thank you in advance!
Pixel[][] data = theImage.getData();
Pixel[][] data2 = new
Pixel[theImage.getWidth()][theImage.getHeight()];
for(int row = theImage.getWidth()-1;row>=0;row--){
for(int col = 0;col<theImage.getHeight();col++){
data2[theImage.getWidth()-1-row][col] = data[row][col];
}
}
theImageData.setData(data2);
**** In java matrix(2 dimensional array) size is fixed. so I have taken the new matrix...
Consider the following matrix transpose routines: typedef int array[4][4]; void transpose (array dst, array src) { int i, j; for (i=0; i<4; i++) { for (j=0; j<4; j++) { dst[i][j] = src[i][j]; } } } void transpose2 (array dst, array src) { int i, j; for (i=0; i<4; i++) { for (j=0; j<4; j++) { dst[j][i] = src[j][i]; } } } Assume this code runs on...
Implement optimized C/C++ code using code optimization
techniques
Consider an image to be represented as a two-dimensional matrix
M, where Mi,j denotes the value of M[i][j] th pixel of M. Pixel
values are triples of red, green, and blue (RGB) values. We will
only consider square images. Let N denote the number of rows (or
columns) of an image (NxN square image). Rows and columns are
numbered, in C-style, from 0 to N-1. Given this representation, the
rotate operation can...
convert the for loop into x86 assembly.. int[][] rotateMatrixBy90Degree(int[][] matrix, int n) { //We need to run the loop for only half the number of rows as it represents one quarter or quadrant for (int layer = 0; layer < n / 2; layer++) { //In every iteration, we reduce number of columns to be swapped by computing first and last column index. We are rotating counter clockwise. int first = layer; //start column pixel of current row...
This is for Java. Create ONE method/function that will return an array containing the row and column of the largest integer i the 2D array. If the largest number is located on row 2, column 1, the method needs to return row 2 and column one. Do not use more than one method. Use the code below as the main. Please comment any changes. in java Given the main, create a method that RETURNS the largest number found in the...
in java / You will: // 1- create a square 2 dimensional array of random size (less than 11) // 2- fill the array with random integers from 1 to the size limit // 3- print the array // 4- prompt to see if the user wants to do another //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // 1- The square can use the same random value for x and y. Don't allow 0 size arrays. // 2- Maybe a nested set of for loops? to...
Hi, can someone please help me implement the transpose,
multiply(Matrix b), multiply(Matrix m, int
threads), and equals(Object in) methods? (This is Java) I really
need help so please don't just refund the question.
public class Matrix {1 public int[] [] matrix; 1 int[] [] trans; 1 public int x, y; 1 private boolean transposed; 1 1 public Matrix(int x, int y){1 matrix = new int[x][y1;1 this.x = x; this.y = y; 1 } 1 9 /*1 * This method takes...
Step 1: Getting Started Create a new .java file named Lab12.java. At the beginning of this file, include your assignment documentation code block. After the documentation block, you will need several import statements. import java.util.Scanner; import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; Next, declare the Lab12 class and define the main function. public class Lab12 { public static void main (String [] args) { Step 2: Declaring Variables For this section of the lab, you will need to declare...
I'm having trouble correctly sorting my 2d array/matrix. I need it so its row-wise sorted (meaning the values in the rows go from low to high). I tried to make the sort function but it just puts all the numbers from lowest to highest, up to down in column format. So please please help me fix it so it sorts correctly, I have bolded the code that needs to be fixed, everything else is fine. The code is below: #include...
JAVA JAR HELP...ASAP
I have the code that i need for my game Connect 4, but i need to
create a jar file . the instructions are below. It has to pass some
parameters. I am really confused on doing so.l I dont know what to
do next. Can someone help me and give detailed descritiopm opn how
you ran the jar file in CMD
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Connect4 {
...