Note that there are some explanatory texts on larger screens.

plurals
  1. PODifference between direct putting 2D array values in image and making a pixel from these values and then putting it
    primarykey
    data
    text
    <p>I am a beginner in digital image processing field. right now i am coding to get an image from 2D array... i have downloaded these two code samples... when i am using the first one i am getting correct image, but when i am using the second one i am getting processed image with more brightness as compared to the previous one.</p> <p>Please suggest me what is the difference between these codes and also which code should i refer... i have to use this code to get my research papers results... </p> <p>1). </p> <pre><code> public BufferedImage getImage(BufferedImage original, float paddedArray[][], int width, int height) { BufferedImage img = new BufferedImage(width, height, original.getType()); for (int i = 0; i &lt; width; i++) { for (int j = 0; j &lt; height; j++) { int c = Math.round(paddedArray[i][j]); int pixel = c &lt;&lt; 16 | c &lt;&lt; 8 | c; img.setRGB(i, j, pixel); } } return img; } </code></pre> <hr> <p>2). </p> <pre><code>public BufferedImage getImages(BufferedImage original, float paddedArray[][], int width, int height) { BufferedImage img = new BufferedImage(width, height, original.getType()); Graphics2D g = (Graphics2D) img.getGraphics(); for (int i = 0; i &lt; width; i++) { for (int j = 0; j &lt; height; j++) { int c = Math.round(paddedArray[i][j]); if (c &gt;= greyRange) { c = greyRange - 1; } g.setColor(new Color(c, c, c)); g.fillRect(i, j, 1, 1); } } return img; } </code></pre> <p>these codes i am using i only want to know the difference between <code>g.setColor(new Color(c, c, c));</code> and <code>img.setRGB(i, j, pixel);</code></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload