カラーマップをデータへ適用

Toru Kano 

読み込んだカラーマップを、実際に何らかのデータに適用してみましょう。

試しに、以下の数式を可視化することを考えます。

\begin{equation} f(x, y) = \left| \cos(x) \cos(y) \right| \end{equation}

描画のソースコードは以下のようになります。
キャンバスサイズは $512\times 512$、$x, y$ の値は適当にスケーリングしてあります。

	// データの色を割り当てて描画(HSB補間)
    private void drawDataActionPerformed(java.awt.event.ActionEvent evt) {                                         
        BufferedImage image = new BufferedImage(lblDraw.getWidth(), lblDraw.getHeight(), BufferedImage.TYPE_INT_BGR);
        int centerX = image.getWidth() / 2;
        int centerY = image.getHeight() / 2;
        for (int y = 0; y < image.getHeight(); y++) {
            for (int x = 0; x < image.getWidth(); x++) {
                image.setRGB(x, y, getColorHSB((float)(255 * Math.abs(Math.cos((double)(x - centerX) * Math.PI / 400.0) * Math.cos((double)(y - centerY) * Math.PI / 400.0)))).getRGB());
            }
        }
        lblDraw.setIcon(new ImageIcon(image));
    } 

結果は以下のようになります。

default.cmp

 apply_default
 

greyscale.cmp

 apply_grey
 

defaultstep.cmp

 apply_step
 

highend.cmp

 apply_high
 

midrange.cmp

 apply_middle
 

lowend.cmp

 apply_low
 

twostep.cmp

 apply_two
 

colorwave.cmp

 apply_wave