Skip to main content

Posts

Mediun Cut Image Compression source code in java

The median cut algorithm is a popular algorithm for color quantization, but can be applied to virtually any point clustering problem. In outline, it works as follows: * Let B be a set of boxes containing points, initially containing only a single box containing all points. * While the number of boxes in B is less than desired number of clusters... o Find the largest side length of any side of any box. o Cut that box into two boxes along its largest side in such a way that half the contained points fall into each new box. o Shrink the two new boxes so that they are just large enough to contain their points. If anyone need any help how to do without my code just post comment I will try to give proper direction to do it. CoDe ***************************************************************************** /** * @(#)box.java * * * @author sharma * @version 1.00 2011/7/8 */ public class Box { publ...

Shift Reduce algorithm source code in c for Compiler

#include #include #include #include #include using namespace std; struct stru1 { char non_ter[1],pro[25]; }cfg[25]; int n,st=-1,j,i,t=-1,m; int v,c,p=1; char str[20],stack[20],ch,tmp[10]; void match(int k); void matchl(int k); int main() { printf("Enter the number of productions:\n"); scanf("%d",&n); printf("\n"); printf("Enter the productions on LEFT and RIGHT sides:\n"); for(i=0;i \n"); scanf("%s",cfg[i].pro); printf("\n"); } printf("Enter the input string:\n"); scanf("%s",str); printf("\n"); i=0; do { ch=str[i]; stack[++st]=ch; tmp[0]=ch; match(1); i++; }while(str[i]!='\0'); c=st; v=st; puts(stack); printf("\n"); while(st) { --st; v=st; t=-1; p=0; while(v<=c) { ...

Iterative Deeping algorithm source code in C++

 Source code of iterative deeping search is given. # include <stdio.h> # include <iostream> # include <sstream> # include <algorithm> # include <string.h> # include <string> # include <math.h> # include <queue> # include <vector> using namespace std; int node,edge; vector<int>adj[100]; bool flag[100]; int dist[100],par[100],leb[100]; int bfs(int s,int e,int lev) {    int i,cur,head,tail,que[10000],l=0;    head = tail = 0;    que[head++] = s;    flag[s] = 1;    dist[s] = 0;    par[s] = -1;    leb[s] = 0;    memset(leb,0,sizeof(leb));    while(head != tail)    {        cur = que[tail++];        if(leb[cur] == lev)        {            return 0 ;      ...

A*Star Serach source code in C++

#include <iostream> #include <string> #include <map> #include <queue> #include <stack> #include <algorithm> #include <list> #include <set> #include <cmath> #include <cstring> #include <stdio.h> #include <string.h> #include <sstream> #include <stdlib.h> #include <vector> #include <iomanip> #include <ctime> using namespace std; int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; int fx,fy,dist[100][100],row,col; int distance(int x,int y,int p,int q); int heuristic(int x,int y); //vector<string>board; int board[100][100]; struct pq {     int x,y,cost,h,total_cost;     pq(int _x,int _y,int _cost)     {         x=_x;y=_y;cost=_cost;         h=heuristic(x,y);         total_cost=cost+h;     ...

3D to 2D object Transform source code in c++ with OpenGL

Here is the implementation of 3d to 2d conversion algorithm in c. INPUT:   OUTPUT: SOURCE CODE : #include <windows.h> #include <GL/glut.h> #include <stdlib.h> #include <stdio.h> #include <iostream> #include <math.h> using namespace std; int x,y,z,sx[100],sy[100],sz[100],ex,ey,ez; void drawLine(int x1, int y1,int x2,int y2) {     glBegin(GL_LINES);     glVertex2i(x1,y1);     glVertex2i(x2,y2);     glEnd(); } static void display(void) {     int i,dis,xx[100],yy[100],px,py;     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);     glColor3d(0,255,255);    /* drawLine(100,200,200,100);     drawLine(200,100,300,200);     drawLine(300,200,200,300);     drawLine(100,200,200,300);*/     //glReadPixels(20...

Client Server MineSweeper source code in Java with remote method invocation

First Create a project with these 3 class. 1.game.java 2.RmiClient.java 3.ReceiveMessageInterface.java /**  * @(#)game.java  *  *  * @author sharma  * @version 1.00 2011/5/5  */  import java.rmi.*; import java.awt.BorderLayout; import java.awt.Color; import javax.swing.JFrame; import javax.swing.JTabbedPane; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JButton; import javax.swing.SwingConstants; import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.awt.Transparency; import javax.swing.event.*; import java.sql.*; import java.util.*; import java.net.URL; import javax.imageio.ImageIO; import java.lang.*; import java.io.*; import javax.swing.BoxLayout; public class game extends JFrame {         RmiClient rm;     JLabel name = new JLabel();     JPanel jPanel1 = new JPanel();     JLabel ...

Image Downloader source code in Java and Manga downloader

import java.io.BufferedOutputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.URL; public class ImagesDownloader {     public static void main(String[] args) throws IOException {         getImages();     }         private static void getImages() throws IOException {         String imagesRootPath = "http://somemanga.com/images2/";               // http://somemanga.com/images2/13342848.jpg             // http://i999.mangareader.net/naruto/538/naruto-2251381.jpg             for (int i = 13342848; i <= 13342848+9; i++) {            ...