|
Not to be funny but it sounds to me like you have no clue of how to program. You have the basic idea of what you want to do but don't know how to write the code. Maybe a good Book for C# beginners??
Excellence is doing ordinary things extraordinarily well.
|
|
|
|
|
You almost got it I'm extremely well versed in gml, and I'm learning quite a bit about linux shell script and little python, but like I said, other than making hello world and a half functional calculator, I'm just about completely lost in C#. I can't stay focused on reading my C# book, and I learn by doing and seeing. Unfortunately, I do not see any examples that will help me, and I've tried so many times and have gotten so many errors during compiling, that I gave up trying. I figured you guys could probably write up my answer in five minutes or at least point me in the right direction, so I came here. Like I said, any help is greatly appreciated, but if no one can (or is willing) to help, then I'll be on my way.
|
|
|
|
|
After a simple Google search you will find this[^].
My failometer is detecting vast quantities of FAIL!
"Its SQL - hardly programming..." (Caslen)
|
|
|
|
|
Wow, I googled for quite a while and never saw this. Might I ask what exactly you googled? Anyhow, this will be a big help, thanks
|
|
|
|
|
'c# image slideshow application' and it was the second result.
My failometer is detecting vast quantities of FAIL!
"Its SQL - hardly programming..." (Caslen)
|
|
|
|
|
Ahh, didn't think of searching slideshow, but that actually works better
|
|
|
|
|
I think the "motto" of the site is show what you have done and where your problem is and the guys will help. There are a few sites with Video Tuts if that would help. Check this site. Development for Beginners[^]
Excellence is doing ordinary things extraordinarily well.
|
|
|
|
|
Hi people,
I want to have a print button in my GUI to print the contents of a panel (control drawn using Graphics class) perhaps to take a screenshot of the panel and print it out as an image.
Does anyone have any idea how I can do this?
Cheers
|
|
|
|
|
0) Don't cross post when your message is not imediatley reposponded to, your going to annoy people that way and they may not be too kind or they just may ignore it. It is considered rude. Have some patience.
1) Google[^]
My failometer is detecting vast quantities of FAIL!
"Its SQL - hardly programming..." (Caslen)
|
|
|
|
|
Sorry !! I didnt know it has been posted twice. the first time I posted it didnt appear on the forum board and gave me a message saying the website is installing some updates.
|
|
|
|
|
Apologies, I didn't know the site was down.
My failometer is detecting vast quantities of FAIL!
"Its SQL - hardly programming..." (Caslen)
|
|
|
|
|
I was working on some image filtering when I saw a problem in my output. After a little while I noticed two possible problems with the code after fixing one of them the output was, strangely enough, correct.
Here's a part of the code:
public struct Pixel
{
public byte r;
public byte g;
public byte b;
public static bool operator >(Pixel p1,Pixel p2)
{
return p1.r + p1.g + p1.b > p2.r + p2.g + p2.b;
}
}
Now my thought here was that since the r,g and b values are bytes, adding them could cause an overflow of the byte. For example: 128,128,128 would add up to 128 and would cause 64+64+64 to be greater then the second example since it adds up to 192 (192>128). However this does not seem to be the case, 128,128,128 seems to add up to 384 which would be impossible with a byte, so is the + operator actually changing my byte to a (u)long, (u)int or (u)short internally. Has anyone found any documentation on this issue, and can I expect this to work on any implementation of c#?
|
|
|
|
|
Hi,
expressions involving 8-bit or 16-bit integer variables (such as the bytes in a pixel) get computed using 32-bit integers, so there is an automatic promotion from byte to int, and the sum is an int. In your case, overflow is not possible.
BTW: this is not only true for C#, it holds true for all C-like languages such as C, C++, Java
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Thanks for your input!
I expected the byte to still behave as a true (8 bits) byte, does this also mean that ints work faster on a 32-bit machine then bytes do since a byte has to be processed to behave as a byte, example:
byte b = (byte)0x04 + (byte)0x10;
would be roughly translated to:
int b = 0xff &((byte)0x04+(byte)0x10);
And would a byte[12] take up the same amount of memory as an int[12] would, or would a byte array simply be a pointer to a field thats of the size int[3]
|
|
|
|
|
That is a lot of questions.
1. speed
Smaller variables typically don't get processed any faster or slower. Modern CPUs are capable of dealing with them very well. And storing the lowest byte or short of an integer is exactly the same as storing a byte or short, i.e. there are instructions that deal with the lower part of a register.
2. memory cost
For single variables, the size is not really important. It only becomes important when you have a lot of them, as in large arrays. In general an array takes a number of bytes equal to the number of elements times the size (in bytes) of a single element. So int[12] is four times larger than byte[12].
Conclusion: don't bother choosing byte/short/int until it becomes relevant, e.g. because:
- you want the overflow to occur (a value that should wrap from 255 to 0 can best be a byte)
- you want to preserve memory (as in images that may hold thousands or millions of pixels)
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Thanks a lot!
Since the size of the pictures I'm dealing with is fairly large (up to 5MP on current devices) and the ammount of memory and CPU power is generally low (PPC's are not that fast), I have had to really keep down on the CPU load and memory usage. I've found your comments to be very helpful.
|
|
|
|
|
you're welcome.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
i have an image of space from which i have to detect objects like stars,so i have to read each pixel's value in image and compare its each pixel's value with its neighbor pixels,if those pixels have same value then those pixels can be one star in space
|
|
|
|
|
It may not be as simple as that. A lot will depend on the quality of your images, and what was used to produce them, and a star will generally not be a simple area of pixels of the same value.
If you want to start writing astronomical image processing software, you should take a close look at a good selection of images from different sources and devices.
There are three kinds of people in the world - those who can count and those who can't...
|
|
|
|
|
molesworth wrote: It may not be as simple as that. A lot will depend on the quality of your images, and what was used to produce them, and a star will generally not be a simple area of pixels of the same value.
Unless the image is in single bit depth, or heavily processed it won't be.
Raw images in prosumer astronomy cameras are 12/16bit color depth, and since typical pixels are sized to have a capacity of between 40-100k electrons sampling noise is a factor in addition to the quantum noise of the chip itself.
Even ignoring noise, unless a star is perfectly centered on the corner between 4 pixels; and the pixels are large enough that all of the diffraction rings are completely on those 4 pixels; and the camera is anti-bloom* or the pixels aren't saturated; or the camera is non anti-bloom and you're only interested in IDing the middle of stars that have bloomed.
* normal daylight use cameras have a gap between each pixel on the sensor to keep them from blooming, this results in roughly 50% of the light falling on dead parts of the chip. For taking images of bright objects this doesn't matter (daylight, moon, planets), but doubles your exposure time for everything else. As a result most astrocams use chips that can bloom and require the user to combine multiple short exposures in post-processing. For most purposes this works better, the only exceptions being trying to image a very faint object next to a very bright one (eg the flame nebula (background for the horsehead)).
It is a truth universally acknowledged that a zombie in possession of brains must be in want of more brains.
-- Pride and Prejudice and Zombies
|
|
|
|
|
Search the articles for "Image processing for dummies". Christian Graus put together a nice set of articles on the subject.
|
|
|
|
|
You're actually thinking the wrong way, you should not compare the pixels to the ones of their neighbours because the stars can be bigger then x pixels.
The easiest way to do this is to convert the image to a binary image first. What you should do is calculate the average pixel value of the image and then creating a bool array of the same size of the image, anything higher then the average becomes true, anything lower becomes false. Then you'll want to do something like labelling to differentiate between different stars so you can cut them out or do whatever you need to do with them.
A tip in advance:
Don't use the getPixel and setPixel methods of the Bitmap, use the LockBits and UnlockBits functions, they are a lot faster..
|
|
|
|
|
Dear terradtc,
thanks for suggesting about lockBits and UnlockBits,basically this is an assignment which our teacher has assigned to do in python using OpenCV library,but unfortunately i don't have any idea about python so i thought i should do it in C#,so kindly if you can give me a code example it would be appreciating,
thanks in Advance
|
|
|
|
|
You should talk to your teacher before changing languages, learning python may be what he wants from you.
If the images are from a specific set he provided, a more simplistic approach may well work.
Christian Graus
Driven to the arms of OSX by Vista.
"I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
|
|
|
|
|
You'll want to do some filtering and maybe change the average a bit since this is very sensitive to minor color differences on space images but the basic idea here works. It also doesn't deserve a beauty prize but for 10 minutes of work, I wasn't expecting it to. Furthermore this code will fail on any image that's not 24 bits per pixel.
class StarGazer
{
// this function works on pictures of up to 1.3 billion pixels in width
public bool[,] toBool(Bitmap bitmap)
{
Rectangle rect = new Rectangle(0, 0, bitmap.Width, bitmap.Height);
System.Drawing.Imaging.BitmapData bmpData =
bitmap.LockBits(rect, System.Drawing.Imaging.ImageLockMode.ReadOnly,
PixelFormat.Format24bppRgb);
bool[,] boolBitmap = new bool[ bitmap.Height,bitmap.Width];
unsafe
{//first we calculate the average value of a pixel
byte* ptr = (byte*)(bmpData.Scan0);
ptr--;
ulong overallAvg = 0UL;
for(int y = 0;y<bitmap.Height;y++)
{
ulong lineAvg = 0UL;
for (int x = 0; x < bitmap.Width; x++)
{
lineAvg+= *(++ptr);
lineAvg+= *(++ptr);
lineAvg+= *(++ptr);
}
overallAvg += lineAvg /(ulong) bitmap.Width;
}
overallAvg /= (ulong)bitmap.Height;
int average = (int)overallAvg;
//we've got the average value a collection of three pixels needs to have to become an object
ptr = (byte*)(bmpData.Scan0);
ptr--;
for (int y = 0; y < bitmap.Height; y++)
{
for (int x = 0; x < bitmap.Width; x++)
{
boolBitmap[y, x] = (*(++ptr) + *(++ptr) + *(++ptr) > average);
}
}
}
bitmap.UnlockBits(bmpData);
return boolBitmap;
}
public Bitmap boolBitmap(bool[,] boolBitmap)
{
Bitmap temp = new Bitmap(boolBitmap.GetLength(1),boolBitmap.GetLength(0));
System.Drawing.Imaging.BitmapData bmpData = temp.LockBits(new Rectangle(0, 0, boolBitmap.GetLength(1), boolBitmap.GetLength(0)), System.Drawing.Imaging.ImageLockMode.ReadWrite, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
int bytes = (temp.Width * temp.Height) * 3;
unsafe
{
byte* ptr = (byte*)bmpData.Scan0;
ptr--;
int x = 0;
while (x < temp.Width * temp.Height)
{
*(++ptr) = *(++ptr) = *(++ptr) = (byte)(boolBitmap[ x /temp.Width,x % temp.Width] ? 255 : 0);
x++;
}
}
temp.UnlockBits(bmpData);
return temp;
}
}
modified on Saturday, May 9, 2009 6:54 AM
|
|
|
|