|
You're right - again!
Programming is work, it isn't finger painting. Luc Pattyn
|
|
|
|
|
Hello,
How to define horizontal profile
For EX; i have a vertical bar on an image of thickness - 40 Width & Height 400 . the possibility of getting defects also possible in bar. so i want to create a horizontal profile of length 0 to 40 ( by taking the uniformity and average pixels from the all 400 length)
so the horizontal profile is going to my reference profile - to verify the defects later .
i don know whether you guys under stand my question..but post me if you didnt
How to create a horizontal profile ??
|
|
|
|
|
Gday,
There's a page at Wikipedia on Fixed Pattern Noise, see here[^].
I think you are (probably) interested in calculating the DSNU.
If this is the case, I believe it involves the following steps.
1. Initialize totalLuminosity to 0.0
2. Create an array of numToProcess (400) elements - lumArray
3. Get pixel value
4. Convert colour(RGB) to HSL (Hus Saturation Luminosity)
5. Add the Luminosity value to totalLuminosity
6. Set lumArray[curPixelNum] to Luminosity
7. If #pixels processed < numToProcess(400) goto #3
8. Divide totalLuminosity by numToProcess(400) - this is your avgLuminosity
9. Create a second array with numToProcess (400) elements - diffArray
10. For each element in array from step 2, set difArray[i] = avgLuminosity - lumArray[i]
This will give you an array that tells you the difference between the brightness of each pixel and the average brightness of all pixels in the line.
Cheers,
S.
|
|
|
|
|
#include<stdio.h>
#include<string.h>
struct student
{
char name[20];
long int phone;
};
int main(void)
{
FILE *fp=fopen("student.txt","w+");
struct student s;
strcpy("dilip",s.name);
s.phone=123456789;
if(fwrite(&s,sizeof(struct student),1,fp)!=1)
printf("error");
fclose(fp);
return 4;
}
//BELOW IS THE UNREADABLE CONTENT WRITTEN TO FILE
//W$§#Â6W$1"ôSß"ÿÿ¢xÐ¥Q
-- modified 15-May-12 11:52am.
|
|
|
|
|
It would help if you put <pre> tags round your code so it looks like:
strcpy("dilip",s.name);
s.phone=123456789;
if(fwrite(&s,sizeof(struct student),1,fp)!=1)
In the above you have a strcpy() call with the source and destination reversed so your copy will fail (possibly silently). You also have a long int in your structure which is not a text value. So combining these two issues your file contains some bytes that do not show as clear text.
Programming is work, it isn't finger painting. Luc Pattyn
|
|
|
|
|
dilipkumarc wrote: strcpy("dilip",s.name);
You have the source and destination reversed.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
consider opening the file for binary writing, because you want to write a struct with an int.
FILE *fp=fopen("student.txt","wb+");
Also, as the others mentioned before, it has to be:
strcpy(s.name, "dilip");
Also think about that:
const int NAME_LEN = 20;
struct student
{
char name[NAME_LEN];
long int phone;
};
char myLongName [] = "this_is_a_very_long_name_largerthan_20_chars";
strncpy(s.name, myLongName, NAME_LEN);
s.name[NAME_LEN - 1] = '\0';
Later on, I guess, you will copy a variable to the string. In the described way, you can be sure, not to overwrite the end of the char array. With only strcpy this could happen.
|
|
|
|
|
When trying to open a USB keyboard device I get "Access is denied".
HANDLE hDevice = CreateFile (
lpDevicePath,
GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
FILE_FLAG_OVERLAPPED,
NULL);
lpDevicePath is: \\?\root#rdp_kbd#0000#{884b96c3-56ef-11d1-bc8c-00a0c91405dd}
If I do not ask for any access, i.e...
HANDLE hDevice = CreateFile (
lpDevicePath,
0,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
FILE_FLAG_OVERLAPPED,
NULL);
I get a valid handle but I get "Access is denied" when I use it to call WinUsb_Initialize().
Any ideas?
Thanks.
“If I had asked people what they wanted, they would have said faster horses.”
― Henry Ford
|
|
|
|
|
See here.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
Thanks David.
“If I had asked people what they wanted, they would have said faster horses.”
― Henry Ford
|
|
|
|
|
How to create Bitmap of 8bpp from 8bpp RAW data?
|
|
|
|
|
0. open a file
1. fill out and write the BITMAPFILEHEADER
2. fill out and write a BITMAPINFOHEADER
3. write the 256 palette entries
4. write the pixel rows, bottom-to-top, padded on the ends so that the rows are multiples of 4 bytes each
5. close the file
|
|
|
|
|
|
Ahhh, well that's a different kettle of fish altogether.
You'll need to look into colour quantization.
You'll have to work out a way of converting the potentially 16.7 million colours into a maximum of just 256 colours. Oct-tree colour quantization is one method that comes to mind. Here's something of a brutal introduction to the topic. http://www.cubic.org/docs/octree.htm[^] By the time I'd implemented that one back around 98 or 99 sometime, I got rid of my 16 bit vid card and replaced it for a tru-colour one. Shame really, but so much easier to work in 24 bit colour.
There are (much much) simpler methods that will work if there are less that 257 distinct colours in the image.
|
|
|
|
|
Hi,
I want to read line from a file and after reading that line i have to delete that line.I think deleting a line in file is difficult.So i thought to replace the line with null string.
For that i coded below..first i test with text "TEST" for updating.But i could not get that.
if ( (fpExe=fopen((LPCTSTR)sExePath, "r+"))!=NULL)
{
while(fgets(List,80,fpExe)!=NULL)
{
sReadLine = List;
off1 = ftell(fpExe);
result = fseek( fpExe, off1,SEEK_SET);
fprintf( fpExe, "%s", "TEST" );
}
fclose(fpExe);
return false;
}
else
{
return false;
}
Example:
INSTRUCTOR1
INSTRUCTOR2
this should become
TEST
TEST
But actually what comes as
INSTRUCTOR1
TESTRUCTOR1
So how can i replace string with null or another string.
|
|
|
|
|
As far as you open the file in read mode, you can not write anything in that file ...
|
|
|
|
|
What are you trying to do, exactly?
If you need to manipulate the content of a file the usual way is:
- Read the file content into memory.
- modify it
- Write the modified content to another file (say "output").
- delete the original file and rename the "output" file you produced with the original filename.
Veni, vidi, vici.
|
|
|
|
|
You cannot do it that way; a file is merely a stream of bytes and overwriting something with a shorter value will leave garbage in the stream. You need to follow something similar to my response here[^], but using text instead of PDF files and changing lines rather than pages. If you want to delete a line then merely read it and ignore it.
Programming is work, it isn't finger painting. Luc Pattyn
|
|
|
|
|
Just to amplify CPalini's answer - if you're doing line oriented I/O then open the file for reading, open another for writing then process each line from the input file putting the results in the output file.
Another thing you could try is have fixed length records in the file. Then to read a record all you have to do is fseek to (record_size * index_of_record) . To replace it you just write to the same place and to erase it you just mark the entry as empty somehow. This means you only need a single file open but makes the logic a bit more complicated.
Cheers,
Ash
|
|
|
|
|
HI guys,
How to read data from a file and save that data
|
|
|
|
|
See here[^], paying particular attention to CreateFile() , ReadFile() and WriteFile() .
[edit]
On second thoughts you may be better to start here[^] for pure C.
[/edit]
Programming is work, it isn't finger painting. Luc Pattyn
|
|
|
|
|
Is there a multiprocessor implementation of qsort and bsearch out there? My app. is mostly in C but some bits have got C++ and STL depending on what libraries are needed. We compile with VS2008 so openMP is available.
|
|
|
|
|
An article I read recently on sorting in parallel: http://www.drdobbs.com/blogs/parallel/232600358?pgno=1[^]
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
|
hi,
i
int COMportNum= 3;
portstream_fd COMstream;
portstream_fd pstream;
char COMportPrefix[10] = "COM";
char COMportName[256];
sprintf(COMportName, "%s%d", COMportPrefix, COMportNum);
strng = CString(COMportName);
strng.Format(_T("%0.9s"), strng);
SetDlgItemText(IDC_STAT, strng);
set_baud_rate(BaudRate);
COMstream = open_host_port(COMportName);
if ( COMstream == PORT_NOT_OPENED )
{
stw.Format(_T("%08X"), GetLastError());
SetDlgItemText(IDC_PTUPORT, stw);
}
else
SetDlgItemText(IDC_PTUPORT, (LPCTSTR) L"Ok");
can anyone please help me with this error.
Regards
Jawad
|
|
|
|