|
thanks for ur instant reply. Actaully how do we know how a format works?..
My images are some medical images.. as far as I know they r X-ray images of spine and i beleive they r taken froms ome x-ray machines and the format may be some proprietery format.
The only data they have given to me is the one that I have given in my previous message.
I have already tried google in many ways, but of no use. It not even giving me atleast one site relating to this.
If u think I should have some more data to convert them or to know how they works, lemme know i would try to know some more data if possible. If u want i can send u a sample file.
thanks,
Pavan.
Pavan
|
|
|
|
|
I'm sorry, I really don't have time to look at a sample file.
IFFCL_GRAY {
bits: 12
byte: @0=0x00
byte: @1=0x00
byte: @2=0x00
byte: @3=0x00
width:[@6=ishort]/2
height:@4=ishort
start_offset:128
line_offset:width*2
datatype: lsb_msb
}
This looks to me like the image is 12 bit greyscale, which means that there are 4096 shades of gray. Given that the line offset is twice the width, each pixel must be stored in 2 bytes, which is fine, given that this gives you 16 bits to play with, it's a case of figuring out which 4 bits are ignored. It also looks like there is a 128 byte header at the top of the file, image data would follow after that. It looks like byte 6 of the header is the width, and btye 4 is the height.
All of this is a wild guess.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Hi Graus,
I am writing a program for this (image format conversion) and i need some advice from u.... as this is a 12 bit greyscale image... can we say tht it is having only 1 layer of data (like tht of tiff images) if tht is the case... using this data how can we convert it into a 24 bit bitmap image (i hope we have to use tht 12 bit information and fill up the 24 bit for each pixel in BMP) if this is correct then how can we generate a 24 bit information from a 12 bit information (i hope we have to do some padding work over here, but how can we perform it).
sorry if i bother u askin these many questions...
thanks in advance,
Suman
|
|
|
|
|
Suman Niranjan wrote:
sorry if i bother u askin these many questions...
Not at all, that's what I invite by writing articles.
Given that the image is greyscale, the red, green and blue components will be the same. Therefore I'd assume that each pixel is defined by all 12 bits, which gives them a range of 4096 values. I'd shift the values by 4, so that you use the 8 most significant bits to define your grey level, then you need to shove that value into each of the red, green and blue values for your 24 bit image.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Hi Graus,
thanks for ur inspiration and suggestion. Here is wht I am plannin to proceed...
1) I would read the file byte by byte using System.IO namespace.
2) As we know tht the width - value at (byte6)/2
and height - value at byte4 and the starting offset of the actual data is from byte 128. So, after reading the width and height , directly i would jump to 128 offset and starting reading the data.
3) Now the actual scene comes in to play... now the data is 12bpp means they used 2 bytes but they actually used 12 bits in it (am i right?), now the problem is, in which direction we have to consider... since they have given data_type: lsb_msb (means the data is written from lsb to msb [right to left]... so should we have to consider the last 12 bits and now here i didn't get how to shift the bits..and which 8 bits to use to define our new greylevel. if this is cleared then i can proceed with creating a bitmap image with correcsponding RGB channels.
please help me out if u can....and guide me if i am goin in wrong direction..
thanks in advance,
Pavan.
Suman
|
|
|
|
|
Hi Graus,
Here is the problem, I am writing a program to find the cornor pixels in an image and i am turnin those cornor pixels to red. I have written my method as below and i have tried it in different ways like using (int)pSrc[..], (byte)255 in if loops, but of no use. I am not able to turn the cornor pixels to red.(Basically for finding the cornor pixels i am checking with it neighborhood pixels whether they are white(255) or not in some fashion. Since the return type is BGR i have tried the reverse order of assignment too (0,0,255).
public static bool Cornors(Bitmap b)
{
Bitmap bSrc = (Bitmap)b.Clone();
BitmapData bmData = b.LockBits(new Rectangle(0, 0, b.Width, b.Height), ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);
BitmapData bmSrc = bSrc.LockBits(new Rectangle(0, 0, bSrc.Width, bSrc.Height), ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);
int stride = bmData.Stride;
int stride2 = stride * 2;
System.IntPtr Scan0 = bmData.Scan0;
System.IntPtr SrcScan0 = bmSrc.Scan0;
unsafe
{
byte * p = (byte *)(void *)Scan0;
byte * pSrc = (byte *)(void *)SrcScan0;
int nOffset = stride - b.Width*3;
int nWidth = b.Width - 2;
int nHeight = b.Height - 2;
for (int y=0;y < nHeight;++y)
{
for (int x=0; x < nWidth; ++x )
{
if (pSrc[3+stride]==255)
{
if ((pSrc[3]==(byte)255 && pSrc[0+stride]==(byte)255)||(pSrc[3]==(byte)255 && pSrc[6+stride]==(byte)255)||(pSrc[3+stride2]==(byte)255 && pSrc[6+stride]==(byte)255)||(pSrc[0+stride]==(byte)255 && pSrc[3+stride2]==(byte)255)||(pSrc[3+stride2]==(byte)255 && pSrc[6+stride]==(byte)255)
||(pSrc[3]==(byte)255 && pSrc[0+stride]==(byte)255 && pSrc[6+stride]==(byte)255)||(pSrc[0+stride]==(byte)255 && pSrc[3+stride2]==(byte)255 && pSrc[6+stride]==(byte)255)
||(pSrc[3]==(byte)255 && pSrc[0+stride]==(byte)255 && pSrc[3+stride2]==(byte)255)||(pSrc[3]==(byte)255 && pSrc[6+stride]==(byte)255 && pSrc[3+stride2]==(byte)255)
||(pSrc[3]==(byte)255 && pSrc[0+stride]==(byte)255 && pSrc[6+stride]==(byte)255 && pSrc[3+stride2]==(byte)255))
{
pSrc[3 + stride]= (byte) 255;
pSrc[4 + stride]= (byte) 0;
pSrc[5 + stride]= (byte) 0;
}
}
p += 3;
pSrc += 3;
}
p += nOffset;
pSrc += nOffset;
}
}
b.UnlockBits(bmData);
bSrc.UnlockBits(bmSrc);
return true;
}
If there is any mistake in my cod ecan u plz lemme know abt it.
thanks in advance,
Pavan.
Pavan
|
|
|
|
|
Pavan Kumar N Tiruveedhula wrote:
pSrc[3]==(byte)255 && pSrc[0+stride]==(byte)255 && pSrc[6+stride]==(
If you're checking for a pixel value, you need to add 2, 1 and 0 to stride, to check all the same pixel.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Thanks Graus, I did get u what u r telling. My idea was based on the image type (I am using a grayscale bitmap image , which is only pure balck and white nomore intermediate graylevels). thts why wht i am thinkin is we can just find whether one of the 3 colors of a pixel is 255 [since white is (255,255,255)] if it is, then we consider its neighboirhood pixels in the form of a 3x3 matrix where our pixel is the center pixel [3+stride]. then i perform the matching operation in second loop, if anyone is true then i would like to change the 3 values of the center pixel to [255,0,0].
Important one is my initial image consists pixels of [0,0,0] and [255,255,255].(if we consider it as RGB)
My fina image ocnsists [0,0,0], [255,0,0](for image conrnor pixel), [255,255,255].
I hope now I am clear.
i think i am goin wrong somewhere between byte and integer conversions, but i am not able to figure it out.
thanks,
Pavan.
Pavan
|
|
|
|
|
I have a tree control that can contain a LOT ( in the order of 100'000+ items ) of highly structured data ( in many trees and subtrees ).
I can select objects from another view,for example a list, in which I have only the name of the item ( or some unique ID ); so I have a list of selected item names.
is there a better way of selecting large quantity of objects in the tree than finding each individual item name ? that's kind of not optimal, O(n-square) (or something like that ) ...
Thanks.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Server.h
class TcpServer
{
...
private:
static map<SOCKET, TcpServer> m_instances;
...
};
When I build this, the compiler reports this:
error C2079: 'std::pair<_Ty1,_Ty2>::second' uses undefined class 'TcpServer'<br />
with<br />
[<br />
_Ty1=const SOCKET,<br />
_Ty2=TcpServer<br />
]
Any solution?
Rickard Andersson
Here is my card, contact me later!
UIN: 50302279
Sonork: 37318
|
|
|
|
|
This is a circular definition - you are trying to use TcpServer inside of itself. You might be able to make the map take a pointer and get it to work:
private:
static map<SOCKET, TcpServer*> m_instances;
An expert is somebody who learns more and more about less and less, until he knows absolutely everything about nothing.
|
|
|
|
|
You just stumbled onto infinity, believe it or not.
When the C++ compiler finds a struct or a class it needs to know the size of it, so that it can allocate correct memory buffers to store the objects in. So when it finds a struct, it goes through each member variable, summing up the size of each member. That's the size the struct will get (not considering alignment issues, but that's not important in this case). Simple addition basically.
So consider this struct:
struct X {
X x;
} What is the size of objects of type X? It's the size of x. So, what's the size of x? Since it's of type X, it's the size of objects of type X. What is the size of objects of type X? ... and so on.
Do you see the infinite recursion here? X depends on itself, and thus its size is undefined, and is rejected by the compiler as an undefined type. A type in C++ is not complete (undefined as the compiler said) unless its size is known.
Navin suggested you could use pointers instead. How does that help you might wonder? The easy answer is that pointers on most platforms come in one size only (this is not entirely true, as old DOS programmers can testify, but don't worry about that for now). On a 32-bit compiler, pointers are typically 4 bytes large. 32 bits = 4 * 8 bits = 4 * 1 bytes. So, by using pointers instead, the compiler can determine the correct size.
--
Arigato gozaimashita!
|
|
|
|
|
I could use a pointer, but what I really don't understand is when a person I met on IRC tried to compile some example code in VC++ 7.1, and it didn't report any errors. I use VC++ 7.0.
Rickard Andersson
Here is my card, contact me later!
UIN: 50302279
Sonork: 37318
|
|
|
|
|
when a compiler compiles != valid code
For your specific problem of looking up a socket object from an socket handle, I would stick with the pointer solution. You probably don't want to waste memory by storing a copy of the whole object in the container.
|
|
|
|
|
I'm working with threads and using GetExitCode. It supposedly returns STILL_ACTIVE but I couldnt find its value in any .h file in the VS folder. The only file it was mentioned in is winbase.h and there its a typedef statement, not a #define.
?
Thanks,
sb
|
|
|
|
|
Hello,
Can someone tell me what the class name of a dialog box is?
The problem is I need to find a specific window and the only two things I know are:
- it is a dialog box (modeless);
- and its window title (static-never-changing string);
Also, if you think there is a better (more correct) way of doing this, please do let me know!
Thank you,
Dave
|
|
|
|
|
About using spy++ and drag the dialog application to spy++ window.
|
|
|
|
|
dNimrod#X wrote:
Can someone tell me what the class name of a dialog box is?
#32770
dNimrod#X wrote:
Also, if you think there is a better (more correct) way of doing this, please do let me know!
By sending a window a WM_GETTEXT message, you risk entering a deadlock state if that window is in a blocked state (i.e., its message pump is not processing messages). I'm not saying that will happen to you here, but it is something you need to consider.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
dNimrod#X wrote:
Can someone tell me what the class name of a dialog box is?
You should try the excellent Spy++ tool which comes with visual studio. It's called spyxx.exe, and it lets you inspect any window. Just hit ALT+F3 when it's started, and a dialog with blue/white icon will show up. Just drag the icon onto any window it'll highlight the window you selected in the tree view. Double click the treeview item or right click it. You can even spy on window messages for any window which is really handy sometimes. Have fun exploring!
--
Arigato gozaimashita!
|
|
|
|
|
U can use the SPY++ utility which comes with VC++ to get these informations
|
|
|
|
|
I have seen this done in a program I don't remember which, where the program woud allow you though and option to show or hide all icons on the desktop.
You can accomplish this manually in WinXP by right clicking on the desktop and selecting
Arrange Icons By | Show Desktop icons.
I have searched everywhere and how not found any info on the subject.
So, please how do you do this programmatically?
Thanks,
|
|
|
|
|
Hai,
I'm new to C++.I'm declaring a function and using it in main.cpp. If I want to use that function in my class say class1.cpp..how should I do that.
Thanks.
|
|
|
|
|
Hello,
If you want to associate the function with the class, exemple use data members from the class without passing them as arguments, make the funtion a member function of the class:
<br />
class A<br />
{<br />
public: <br />
void YourFunction();<br />
};<br />
If you want to call that function from a member function (say constructor) you can do this (there's nothing special about it...)
<br />
A::A()<br />
{<br />
YourFunction();<br />
}<br />
Hope this helps..
Multiply it by infinity and take it beyond eternity and you'll still have no idea about what I'm talking about.
|
|
|
|
|
Hai ..
Thanks o lot..but i think my question is different ..I'm declaring the function in main.
it's somewhat like this..
void myfuntion()
main()
{
..
myfunction();
}
myfunction()
{
...
}
class A
{
public:
void mysecondfunc();
}
void A::mysecondfunc()
{
myfunction(); --->if I use like this it is giving error identifier undeclared, not found
}
how should resolve this..
Thanks again.
|
|
|
|
|
Hello,
In that case, you simply need to declare the function before you use it. The most common case would be in a header file. The implementation is done in the corresponding .cpp file. For exemple:
Consider your function MyFunc, in the header file (say MyHeader.h) you declare the function like this: void MyFunc();
You define the function in the implementation file say MyFunc.cpp like this:
<br />
void MyFunc()<br />
{<br />
}<br />
Whenever you want to use MyFunc, just include MyFunc.h at the top of the file where you use the function.
Multiply it by infinity and take it beyond eternity and you'll still have no idea about what I'm talking about.
|
|
|
|
|