JAVA PROJECT Image Compressor There are a number of schemes
JAVA PROJECT: Image Compressor
There are a number of schemes to compress images so that they don’t take up as much space as they might otherwise. Schemes include: § jpg § jpeg-2 § gif § png § wavelet Your task is to see if you can come up with something more efficient. Ideally it will have the nice property than jpg does, such that when you blow up images they still look reasonable. Here is the gist of an idea of how you might proceed. 1. First detect sharp edges. They break the image into regions bounded by sharp edges. 2. Define the boundaries using spline interpolation or other technique that tends to form nice smooth round edges. 3. Consider each region separately. Split it into three images, a red, green and blue. Now draw a contour map of the region using the intensity of each colour as the Z-axis height. 4. You will see concentric circles around each point representing a local maximum or local minimum. At the center point to your list of sample points, along with its intensity value. 5. Add some more sample points around the boundary. 6. Now recreate the original image smoothly interpolating just from your sample points. 7. Compute the error at each point. 8. Add the worst error point to the sample set. 9. Recreate the image with the new interpolation information. 10. Repeat with the other two colour separations. 11. Repeat until your error is sufficiently small or your sample set is as large at the user is willing to tolerate. I would presume this technique will not do as well as those with a mathematical foundation, but it would fun to try. Go after the niche where you are willing to spend a lot of time compressing for a small gain. Alternatively, you might read up on how existing compression schemes work and see if you can find some tweak to make them a tiny bit better
Solution
database:
create table student_info(stu_id number,stu_name varchar2(20),stu_add varchar2(20));
delete demo:
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.sql.*;
public class DeleteDemo extends HttpServlet
{
public void doPost(HttpServletRequest req,HttpServletResponse res)
{
Connection con = null;
PreparedStatement ps = null;
int rs = 0;
try
{
PrintWriter pw = res.getWriter();
res.setContentType(\"text/html\");
pw.println(\"<html><form target = \'display\'>\");
int sid = Integer.parseInt(req.getParameter(\"stu_id\"));
Class.forName(\"oracle.jdbc.driver.OracleDriver\");
con = DriverManager.getConnection(\"jdbc:oracle:thin:@localhost:1521:XE\",\"scott\",\"tiger\");
ps = con.prepareStatement(\"delete from student_info where stu_id=?\");
ps.setInt(1,sid);
rs = ps.executeUpdate();
if(rs!=1)
pw.println(\"<h2>Student id is problem</h2>\");
else
pw.println(\"<h2 style = \'position:absolute;left:50;top:50\'>One Record Deleted</h2>\");
ps.close();
con.close();
}
catch(Exception e)
{
e.printStackTrace();
}
}
public void doGet(HttpServletRequest req,HttpServletResponse res)
{
try{
doPost(req,res);
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
insert:
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.sql.*;
public class InsertDemo extends HttpServlet
{
public void doPost(HttpServletRequest req,HttpServletResponse res)
{
Connection con = null;
PreparedStatement ps = null;
int rs = 0;
try
{
PrintWriter pw = res.getWriter();
res.setContentType(\"text/html\");
pw.println(\"<html><form target = \'display\'>\");
int sid = Integer.parseInt(req.getParameter(\"stu_id\"));
String sname = req.getParameter(\"stu_name\");
String sadd = req.getParameter(\"stu_add\");
Class.forName(\"oracle.jdbc.driver.OracleDriver\");
con = DriverManager.getConnection(\"jdbc:oracle:thin:@localhost:1521:XE\",\"scott\",\"tiger\");
System.out.println(\"connection\");
ps = con.prepareStatement(\"insert into student_info values(?,?,?)\");
ps.setInt(1,sid);
ps.setString(2,sname);
ps.setString(3,sadd);
rs = ps.executeUpdate();
if(rs!=1)
pw.println(\"<h2>Record is problem</h2>\");
else
pw.println(\"<h2 style = \'position:absolute;left:50;top:50\'>One Record Inserted Successfully</h2>\");
ps.close();
con.close();
}
catch(Exception e)
{
e.printStackTrace();
}
}
public void doGet(HttpServletRequest req,HttpServletResponse res)
{
try
{
doPost(req,res);
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
update:
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.sql.*;
public class UpdateDemo extends HttpServlet
{
public void doPost(HttpServletRequest req,HttpServletResponse res)
{
Connection con = null;
PreparedStatement ps = null;
int rs = 0;
try
{
PrintWriter pw = res.getWriter();
res.setContentType(\"text/html\");
pw.println(\"<html><form target = \'display\'>\");
int sid = Integer.parseInt(req.getParameter(\"stu_id\"));
String sname = req.getParameter(\"stu_name\");
String sadd = req.getParameter(\"stu_add\");
Class.forName(\"oracle.jdbc.driver.OracleDriver\");
con = DriverManager.getConnection(\"jdbc:oracle:thin:@localhost:1521:XE\",\"scott\",\"tiger\");
ps = con.prepareStatement(\"update student_info set stu_name=?,stu_add=? where stu_id=?\");
ps.setString(1,sname);
ps.setString(2,sadd);
ps.setInt(3,sid);
rs = ps.executeUpdate();
if(rs!=1)
pw.println(\"<h2>Student ID problem</h2>\");
else
pw.println(\"<h2 style = \'position:absolute;left:50;top:50\'>One Record Updated</h2>\");
ps.close();
con.close();
}
catch(Exception e)
{
e.printStackTrace();
}
}
public void doGet(HttpServletRequest req,HttpServletResponse res)
{
try
{
doPost(req,res);
}
catch(Exception e)
{
e.printStackTrace();
}
}
}


