i need tips for implimintiing this class:
http://www.cs.huji.ac.il/~intro2cs/doc/ex4/doc/index.html
thanks
10 1146
i mean for the last methods
i mean for the last methods
Be more specific. What exactly do you need help with?
Be more specific. What exactly do you need help with?
i need help in the animate,rotate and blur methods please!!
i am waiting for ideas!!
thanks .
i need help in the animate,rotate and blur methods please!!
i am waiting for ideas!!
thanks .
Have you written code that is using these methods? You are still not being clear.
Have you written code that is using these methods? You are still not being clear.
no my job first is to compile this class without error then use a tester to check the class i mean the driver will just use this class checking if it working right.
at fisrt we construct an image(matrix) and filling it with certain luminosity according to the constructor and then do all the other methods on our image.
i mean i need the function("trick") in doing this methods mentioned abbove.
we mainly use arrys and loops with rows and columns to introrduce the image.
no my job first is to compile this class without error then use a tester to check the class i mean the driver will just use this class checking if it working right.
at fisrt we construct an image(matrix) and filling it with certain luminosity according to the constructor and then do all the other methods on our image.
i mean i need the function("trick") in doing this methods mentioned abbove.
we mainly use arrys and loops with rows and columns to introrduce the image.
To compile the class you need the source code for that class. Do you have it?
To compile the class you need the source code for that class. Do you have it?
that what i am asking for i need help in writing the source code of these methods mentioned above!!
that what i am asking for i need help in writing the source code of these methods mentioned above!!
Interesting. Now where are you so far with it?
Interesting. Now where are you so far with it?
i am still writing the other methods : - ##################
-
import intro2cs.utils.*;
-
####################
-
-
import intro2cs.Ex4.IntroError;
-
-
-
public class MonochromImage {
-
-
private int _width;
-
private int _height;
-
private int[][] _image;
-
private int luminosity;
-
public static int datapix;
-
public static int value;
-
public static int temppix;
-
public static final int ERROR_BAD_PARM= 2;
-
public static final int ERROR_GENERAL= 1;
-
public static final int ERROR_PARAM_BOUND= 3;
-
public static final int ERROR_UNKNOWN= 0;
-
public static final int BG_DEFAULT = 255;
-
* Represents a clock-wise rotation of 90 degrees
-
*************************************************************************/
-
public static final int ROTATE_90CW = 1;
-
/*************************************************************************
-
* Represents a 180 degree rotation
-
-
public static final int ROTATE_180 = 2;
-
public MonochromImage(int height, int width, int luminosity) {
-
-
if(width>=0) _width=width;
-
else
-
IntroError(ERROR_BAD_PARAM,"width is not positive");
-
if(height>=0) _height=height;
-
else
-
IntroError(ERROR_BAD_PARAM,"height is not positive");
-
if(luminosity>=0&&luminosity<=255) _luminosity=luminosity;
-
else
-
IntroError(ERROR_PARAM_BOUND,"luminosity is out of bound");
-
for(int i=0;i<_heigth;i++){
-
for(j=0;j<_width;j++)
-
{
-
_image[i][j]=liminosity;
-
}
-
}
-
-
-
}
-
-
public MonochromImage(int height, int width){
-
-
if(width>=0) _width=width;
-
else row
-
IntroError(ERROR_BAD_PARAM,"width is not positive");
-
if(height>=0) _height=height;
-
else
-
IntroError(ERROR_BAD_PARAM,"height is not positive");
-
-
_luminosity=BG_DEFAULT;
-
for(int i=1,i<height;i++){
-
for(int j=1;j<width;j++)
-
{
-
_image[i][j]=_luminosity;
-
}
-
-
}
-
}
-
-
/*************************************************************************
-
*************************************************************************/
-
public MonochromImage(MonochromImage source) {
-
-
if(source==NULL) IntroError(ERROR_GENERAL,"source is empty");
-
this(source.getWidth,source.getHieght);
-
-
-
-
}
-
-
/*************************************************************************
-
-
*************************************************************************/
-
public MonochromImage(int[][] data){
-
-
image = new int[][];
-
_image=image.setData(data);
-
}
-
-
/*************************************************************************
-
-
*************************************************************************/
-
public int getHeight(){
-
return _height;
-
-
-
}
-
-
/*************************************************************************
-
-
*************************************************************************/
-
public int getWidth()
-
return _width;
-
}
-
-
/*************************************************************************
-
-
*************************************************************************/
-
public int getValue(int row, int column){
-
if(row>_height-1||row<0)
-
IntroError(ERROR_PARM_BOUND,"the row index is out of bound");
-
if(column>_width-1||column<0)
-
IntroError(ERROR_PARAM_BOUND,"the column index is out of bound")
-
datapix=_image[row-1][column-1];
-
return datapix;
-
}
-
-
/************************************************************************
-
-
public int setValue(int row,int column, int luminosity){
-
if(((row<0)||(row>_height-1))||((column<0)||(column>_width-1)))
-
IntroError(ERROR_PARAM_BOUND);
-
if((luminosity<0)||(luminosity>255) IntroError(ERROR_PARAM_BOUND));
-
_image[row][column]=luminosity;
-
value=_image[row][column];
-
return value;
-
-
}
-
-
/*************************************************************************
-
-
*************************************************************************/
-
public int[][] getData(){
-
for(int i=0;i<data[i].length();i++){
-
-
newimage = new int[_height][_width];
-
for(int i=0;i<_height;i++) {
-
for(int j=0;j<_width;j++)
-
newimage[i][j]=_image[i][j];
-
}
-
return newimage;
-
}
-
-
/*************************************************************************
-
-
*************************************************************************/
-
public MonochromImage setData(int[][] data){
-
if(data==null) Intro2Error(GENERAL_ERROR,"data is null");
-
-
-
-
for(int i=0;i<data[i].length();i++){
-
-
tempmax=i;
-
if(tempmax>max)
-
max=tempmax;
-
}
-
-
_width=max;
-
-
-
_image = new int[_height][_width];
-
-
for(i=0;i<_height;i++) {
-
for(j=0;j<_width;j++)
-
_image[i][j]=BG_DEFAULT;
-
}
-
-
for(int i=0;i<data.length;i++){
-
for(int j=0;j<data[j].length;j++)
-
{
-
if(data[i]][j]==null) IntroError(ERROR_PARAM_BOUND);
-
else
-
if(data[i][j]<0) _image[i][j]=0;
-
else
-
if(data[i][j]>255) _image[i][j]=255;
-
else
-
_image[i][j]=data[i][j];
-
}
-
-
-
-
}
-
-
-
/*************************************************************************
-
-
*************************************************************************/
-
public MonochromImage blur(int radius){
-
-
return this;
-
-
}
-
-
/*************************************************************************
-
-
*************************************************************************/
-
public MonochromImage rotate(int rotation){
-
-
return this;
-
}
-
-
/*************************************************************************
-
-
*************************************************************************/
-
public MonochromImage flipVertical(){
-
-
for(i=0;i<_height;i++){
-
for(j=0;j<_width/2;j++){
-
temppix=_image[i][j];
-
_image[i][j]=image[i][_width-i-1];
-
_image[i][j]=temppix;
-
}
-
}
-
return this;
-
}
-
-
/*************************************************************************
-
-
*************************************************************************/
-
public MonochromImage flipHorizontal(){
-
-
for(i=0;i<_height/2;i++) {
-
for(j=0;j<_width;j++)
-
temppix=_image[i][j];
-
_image[i][j]=_image[_height-j-1][i];
-
_image[i][j]=temppix;
-
return this;
-
}
-
-
/*************************************************************************
-
-
*************************************************************************/
-
public MonochromImage imprint(MonochromImage source, int row, int column){
-
-
-
if(source==null) return source;
-
else
-
if((row>_height)&&(column>_width)) return source;
-
-
-
-
-
-
-
return this;
-
}
-
-
/*************************************************************************
-
-
*************************************************************************/
-
public MonochromImage imprint(MonochromImage source){
-
-
return this;
-
}
-
-
/*************************************************************************
-
-
*************************************************************************/
-
public MonochromImage add(MonochromImage source, int row, int column){
-
-
return this;
-
}
-
-
/*************************************************************************
-
-
*************************************************************************/
-
public MonochromImage add(MonochromImage source){
-
-
return this;
-
}
-
-
/*************************************************************************
-
-
*************************************************************************/
-
public MonochromImage add(int luminosity){
-
-
return this;
-
}
-
-
for(int i=1;i<data[i].length();i++){
-
-
tempmax=i;
-
if(tempmax>max)
-
max=tempmax;
-
}
-
-
_width=max;
-
_image = new int[_height][_width];
-
for(int i=0;i<data.length;i++){
-
for(int j=0;j<data[j].length;j++)
-
{
-
if(data[i][j]<0) _image[i][j]=0;
-
else
-
if(data[i][j]>255) _image[i][j]=255;
-
else
-
_image[i][j]=data[i][j];
-
-
for(int i=0;i<_image.length;i++){
-
for(j=data[j].length+1;j<_image[_width].length;j++)
-
{
-
_image[i][j]=BG_DEFAULT;
-
}
-
}
-
-
/*************************************************************************
-
i am still writing the other methods : - ##################
-
import intro2cs.utils.*;
-
####################
-
-
import intro2cs.Ex4.IntroError;
-
-
-
public class MonochromImage {
-
-
private int _width;
-
private int _height;
-
private int[][] _image;
-
private int luminosity;
-
public static int datapix;
-
public static int value;
-
public static int temppix;
-
public static final int ERROR_BAD_PARM= 2;
-
public static final int ERROR_GENERAL= 1;
-
public static final int ERROR_PARAM_BOUND= 3;
-
public static final int ERROR_UNKNOWN= 0;
-
public static final int BG_DEFAULT = 255;
-
* Represents a clock-wise rotation of 90 degrees
-
*************************************************************************/
-
public static final int ROTATE_90CW = 1;
-
/*************************************************************************
-
* Represents a 180 degree rotation
-
-
public static final int ROTATE_180 = 2;
-
public MonochromImage(int height, int width, int luminosity) {
-
-
if(width>=0) _width=width;
-
else
-
IntroError(ERROR_BAD_PARAM,"width is not positive");
-
if(height>=0) _height=height;
-
else
-
IntroError(ERROR_BAD_PARAM,"height is not positive");
-
if(luminosity>=0&&luminosity<=255) _luminosity=luminosity;
-
else
-
IntroError(ERROR_PARAM_BOUND,"luminosity is out of bound");
-
for(int i=0;i<_heigth;i++){
-
for(j=0;j<_width;j++)
-
{
-
_image[i][j]=liminosity;
-
}
-
}
-
-
-
}
-
-
public MonochromImage(int height, int width){
-
-
if(width>=0) _width=width;
-
else row
-
IntroError(ERROR_BAD_PARAM,"width is not positive");
-
if(height>=0) _height=height;
-
else
-
IntroError(ERROR_BAD_PARAM,"height is not positive");
-
-
_luminosity=BG_DEFAULT;
-
for(int i=1,i<height;i++){
-
for(int j=1;j<width;j++)
-
{
-
_image[i][j]=_luminosity;
-
}
-
-
}
-
}
-
-
/*************************************************************************
-
*************************************************************************/
-
public MonochromImage(MonochromImage source) {
-
-
if(source==NULL) IntroError(ERROR_GENERAL,"source is empty");
-
this(source.getWidth,source.getHieght);
-
-
-
-
}
-
-
/*************************************************************************
-
-
*************************************************************************/
-
public MonochromImage(int[][] data){
-
-
image = new int[][];
-
_image=image.setData(data);
-
}
-
-
/*************************************************************************
-
-
*************************************************************************/
-
public int getHeight(){
-
return _height;
-
-
-
}
-
-
/*************************************************************************
-
-
*************************************************************************/
-
public int getWidth()
-
return _width;
-
}
-
-
/*************************************************************************
-
-
*************************************************************************/
-
public int getValue(int row, int column){
-
if(row>_height-1||row<0)
-
IntroError(ERROR_PARM_BOUND,"the row index is out of bound");
-
if(column>_width-1||column<0)
-
IntroError(ERROR_PARAM_BOUND,"the column index is out of bound")
-
datapix=_image[row-1][column-1];
-
return datapix;
-
}
-
-
/************************************************************************
-
-
public int setValue(int row,int column, int luminosity){
-
if(((row<0)||(row>_height-1))||((column<0)||(column>_width-1)))
-
IntroError(ERROR_PARAM_BOUND);
-
if((luminosity<0)||(luminosity>255) IntroError(ERROR_PARAM_BOUND));
-
_image[row][column]=luminosity;
-
value=_image[row][column];
-
return value;
-
-
}
-
-
/*************************************************************************
-
-
*************************************************************************/
-
public int[][] getData(){
-
for(int i=0;i<data[i].length();i++){
-
-
newimage = new int[_height][_width];
-
for(int i=0;i<_height;i++) {
-
for(int j=0;j<_width;j++)
-
newimage[i][j]=_image[i][j];
-
}
-
return newimage;
-
}
-
-
/*************************************************************************
-
-
*************************************************************************/
-
public MonochromImage setData(int[][] data){
-
if(data==null) Intro2Error(GENERAL_ERROR,"data is null");
-
-
-
-
for(int i=0;i<data[i].length();i++){
-
-
tempmax=i;
-
if(tempmax>max)
-
max=tempmax;
-
}
-
-
_width=max;
-
-
-
_image = new int[_height][_width];
-
-
for(i=0;i<_height;i++) {
-
for(j=0;j<_width;j++)
-
_image[i][j]=BG_DEFAULT;
-
}
-
-
for(int i=0;i<data.length;i++){
-
for(int j=0;j<data[j].length;j++)
-
{
-
if(data[i]][j]==null) IntroError(ERROR_PARAM_BOUND);
-
else
-
if(data[i][j]<0) _image[i][j]=0;
-
else
-
if(data[i][j]>255) _image[i][j]=255;
-
else
-
_image[i][j]=data[i][j];
-
}
-
-
-
-
}
-
-
-
/*************************************************************************
-
-
*************************************************************************/
-
public MonochromImage blur(int radius){
-
-
return this;
-
-
}
-
-
/*************************************************************************
-
-
*************************************************************************/
-
public MonochromImage rotate(int rotation){
-
-
return this;
-
}
-
-
/*************************************************************************
-
-
*************************************************************************/
-
public MonochromImage flipVertical(){
-
-
for(i=0;i<_height;i++){
-
for(j=0;j<_width/2;j++){
-
temppix=_image[i][j];
-
_image[i][j]=image[i][_width-i-1];
-
_image[i][j]=temppix;
-
}
-
}
-
return this;
-
}
-
-
/*************************************************************************
-
-
*************************************************************************/
-
public MonochromImage flipHorizontal(){
-
-
for(i=0;i<_height/2;i++) {
-
for(j=0;j<_width;j++)
-
temppix=_image[i][j];
-
_image[i][j]=_image[_height-j-1][i];
-
_image[i][j]=temppix;
-
return this;
-
}
-
-
/*************************************************************************
-
-
*************************************************************************/
-
public MonochromImage imprint(MonochromImage source, int row, int column){
-
-
-
if(source==null) return source;
-
else
-
if((row>_height)&&(column>_width)) return source;
-
-
-
-
-
-
-
return this;
-
}
-
-
/*************************************************************************
-
-
*************************************************************************/
-
public MonochromImage imprint(MonochromImage source){
-
-
return this;
-
}
-
-
/*************************************************************************
-
-
*************************************************************************/
-
public MonochromImage add(MonochromImage source, int row, int column){
-
-
return this;
-
}
-
-
/*************************************************************************
-
-
*************************************************************************/
-
public MonochromImage add(MonochromImage source){
-
-
return this;
-
}
-
-
/*************************************************************************
-
-
*************************************************************************/
-
public MonochromImage add(int luminosity){
-
-
return this;
-
}
-
-
for(int i=1;i<data[i].length();i++){
-
-
tempmax=i;
-
if(tempmax>max)
-
max=tempmax;
-
}
-
-
_width=max;
-
_image = new int[_height][_width];
-
for(int i=0;i<data.length;i++){
-
for(int j=0;j<data[j].length;j++)
-
{
-
if(data[i][j]<0) _image[i][j]=0;
-
else
-
if(data[i][j]>255) _image[i][j]=255;
-
else
-
_image[i][j]=data[i][j];
-
-
for(int i=0;i<_image.length;i++){
-
for(j=data[j].length+1;j<_image[_width].length;j++)
-
{
-
_image[i][j]=BG_DEFAULT;
-
}
-
}
-
-
/*************************************************************************
-
Might be a bit tricky giving ideas on this since you are using packages that I do not have.
Ok did you test the methods that you have written so far?
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Serge Calderara |
last post by:
dear all,
when I use classes function from framework, I could see a
small tooltips wich is showing parameters to pass to the
function but in addition a brief derscription of each.
When doing...
|
by: Maurice |
last post by:
Hi,
We are implementing some wrappers in C++ according to the Adapter
Pattern. The classes and their methods in the Adaptee classes
(open-source library) have already the interface that we like,...
|
by: Martyn Lawson |
last post by:
Hi,
I am currently working as an Analyst on a .NET Web Project using ASP.NET and
C#.NET.
I have a couple of, at least what should be, quick questions:
1. My understanding of UML says that...
|
by: Frans Bouma |
last post by:
Hi,
I have a serious problem with VB.NET and a DataTable derived class and I
can't figure out how to solve it. I have implemented it in C# where it
works perfectly, but I can't port one...
|
by: Yuri CHUANG |
last post by:
"No newline at the end of your output" is really a problem? I've never
learned that before.
So I desire to know some tips about writting a program perfectly.Can
anyone give me some tips which are...
|
by: phl |
last post by:
hi,
My question is:
1. To avoid possible memory leaks, when you use this pattern, after you
have dealth with the unmanaged resources and before you take your
object off the finalize queue,...
|
by: JoeC |
last post by:
I have read books and have ideas on how to create objects. I often
create my own projects and programs. They end up getting pretty
complex and long. I often use objects in my programs they are...
|
by: Joseph Geretz |
last post by:
I have the following class which I am serializing and passing back and forth
between my Web Service application and the client.
public class Token : SoapHeader
{
public string SID;
public...
|
by: koonda |
last post by:
Hi all,
I am a student and I have a project due 20th of this month, I mean May 20, 2007 after 8 days. The project is about creating a Connect Four Game. I have found some code examples on the...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
| |