package ip.apurva;
import ip.color.Ccir601_2cbcr;
import ip.gui.frames.ColorFrame;
import ip.gui.ConvolutionUtils;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import utils.MyMath;
public class FouSyn extends MyZipFile implements ActionListener {
MenuBar mb = getMenuBar();
Menu Fou_menu = new Menu("Fourier Synthesis");
MenuItem FouMountain = addMenuItem(Fou_menu, "Mountain scene");
public void actionPerformed(ActionEvent e) {
if (match(e, FouMountain)) {
fou_mi();
return;
}
super.actionPerformed(e);
}
public void fou_mi() {
initframe();
}
public void initframe() {
imageRandom();
fftR2();
Ccir601_2cbcr cc = new Ccir601_2cbcr(new ColorFrame("colorframe"));
cc.fromRgb();
cc.oneOnF();
cc.toRgb();
ifftR2();
threeDImage();
short2Image();
}
public void imageRandom() {
for (int i = 0; i < getR().length; i++) {
for (int j = 0; j < getR()[0].length; j++) {
int s = MyMath.rand(0, 255);
getR()[i][j] += s;
getB()[i][j] += s;
getG()[i][j] += s;
}
}
}
public void threeDImage() {
graphics.idx.Application.image3D(getImage(), getR());
return;
}
public void multOneonF() {
int xc = getImageWidth() / 2;
int yc = getImageHeight() / 2;
for (int x = 0; x < getImageWidth(); x++) {
for (int y = 0; y < getImageHeight(); y++) {
double f = oneOnF(x, y, xc, yc);
getR()[x][y] = (short) (getR()[x][y] * f);
getG()[x][y] = (short) (getG()[x][y] * f);
getB()[x][y] = (short) (getB()[x][y] * f);
}
}
short2Image();
}
public static double oneOnF(int x, int y, double xc, double yc) {
double dx = x - xc;
double dy = y - yc;
double dx2 = dx * dx;
double dy2 = dy * dy;
double eps = 1;
return 1 / Math.sqrt(dx2 + dy2 + eps);
}
FouSyn() {
mb.add(Fou_menu);
setMenuBar(mb);
repaint();
}
public static void main(String args[]) {
new FouSyn();
}
}