|
It depends on what you wish to do with this algorithm. If you intend to make some kind of bot software for signing up on forums, for example, and posting advertisements, then you will quickly be shunned, and it is likely that you or your post may be removed from these forums. If, however your intentions are good, then somebody is likely to help you. Please detail your exact use for this algorithm.
|
|
|
|
|
I'm looking to convert a jpg image to a text file or at least into some format that is readable even if it's in hex or ASCII. Basically I want to convert the jpg to data then use a portion of it to be compared to another similar data set. The thing is I'm really new to this programming thing and I'm not sure if I'm asking for the impossible.
If anyone could give me some advice on this it would be grand. The language I'm using is c++ but before I can even write the code for it I need to find the conversion
method.
|
|
|
|
|
Please don't cross post
I have no idea what I just said. But my intentions were sincere.
|
|
|
|
|
Ed.Poore wrote: Are you wanting to compare parts of the original file (which may change due to compression etc) or are you trying to compare pixel colours etc?
Sorry about the cross posting wasn't sure where the best place for this type of question was going to be.
but since you ask..
yes parts of the original to parts of a stored copy. The compression should be the same as they will be the same format and size and if I have this right in my head the vectors will be of a very specific portion of the image. pixel colours won't help much as it's all in black and white. at least till I get told otherwise hahahahaha
|
|
|
|
|
A jpg IS data!
Is the jpg an image of text that you want to convert into editable text (OCR)?
Or do you just want to convert the raw binary data into a string?
Or do you just want to compare to jpg's?
|
|
|
|
|
eggsovereasy wrote: Or do you just want to convert the raw binary data into a string?
Or do you just want to compare to jpg's?
A bit of both really. I only want to use a portion of the data in the jpg not all. if I can extract only the part I need I can discard the unwanted data(save space and speed possibly) and use the converted data for my comparison.
I've found lots of information on how a jpg's data is structured but not on how to convert it to a form that can be read. No text in the image.
|
|
|
|
|
Lowki wrote: I've found lots of information on how a jpg's data is structured but not on how to convert it to a form that can be read. No text in the image.
Can you explain (carefully) what you're trying to accomplish here? Do you want to perform OCR on the image or are you just getting confused ?
I have no idea what I just said. But my intentions were sincere.
|
|
|
|
|
Confusion is always part of the problem it's what makes it fun. OCR seemed to me to be a longer way around what I was trying to do I have samples of 106 images each with a unique identifying symbol. I want to take the bit of data with the symbol on it and compare it to a database of all the other symbols till it matches the one it's being compared to. Recognition of sorts. I thought (perhaps wrongly) that it would be simpler to convert the images to raw data like ascii or hex or just raw text code even and cut the bit that has the symbol in it. If I took another image and made it the same size made it blank and experimented on where the data changes as lines are added to it I could in theory work out which portion of the code I would need to cut out. I'm all very new to it all so this may not be feasible which is why I'm asking the question.
|
|
|
|
|
For jpegs this is not possible to my understanding because of the nature of the compression, I seem to remember somewhere that it compresses in swirls rather than lines and I don't think that two images that look the same will look similar on disk when they're compressed.
So I think you'll have to decompress the whole image first, after that you could either use OCR or just pattern recognition but you'll have to decompress it first I think.
I have no idea what I just said. But my intentions were sincere.
|
|
|
|
|
decompress? ah ... I see.. right then.
|
|
|
|
|
Undestand now ?
I have no idea what I just said. But my intentions were sincere.
|
|
|
|
|
I get the jist of it. Decompressing the a jpg seems to be bit problematic .I've been looking for info on how that’s done and it's proving a bit fruitless ,will just have to keep looking. I did manage to open the jpgs with a hex editor but that’s not going to help me much. As you said the encryption is quite involved on jpgs. If even one pixel is different it changes the entire hex code aside from the first chuck which I assume would be the size and thumbnail information. But after that it even changes the image information in hex if you've saved onto the same image without making any changes. I'm hoping that decompressing the jpg will give me more of a standardised result otherwise the variables are going to be enormous
|
|
|
|
|
Take a look at http://www.ijg.org/[^] there's some links there for C code to decompress JPEGs I think.
I have no idea what I just said. But my intentions were sincere.
|
|
|
|
|
Lowki wrote: I'm hoping that decompressing the jpg will give me more of a standardised result otherwise the variables are going to be enormous
I guess that depends on how you do the comparison, and what you are trying to compare. Comparing byte for byte with a lossy graphics compression is definitely problematic. However, doing pattern matching and image tracking/finding can be done if the choice of sub-images you are looking for have high contrast and are few in number (you are looking for a few possible symbols rather than every possible symbol in a plethora of possibilities). You can grade matching results through a bayesian or other fuzzy comparison, and then find the "best match" which is as much as you can hope for when dealing with jpeg (lossy) compression.
_________________________
Asu no koto o ieba, tenjo de nezumi ga warau.
Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
|
|
|
|
|
Hi,
In general you can compare uncompressed JPEG images. JPEG is a lossy compression scheme, but, don't forget, the intent of it is to compress with minimal visual loss. So, all you have to do, is a visual comparator.
The visual comparator is diferent from a normal comparator in the sence that it must tolerate local deviations. For example, maybe you can consider that 2 images are the same if their JPEG comparison results in a 1% overall difference.
The visual comparator should focus mainly on luminance (the average of the three RGB components). This is because JPEG dedicates about 80% of the resulting bits to luminance and only about 20% to chrominance. So, in general, color looses much more in JPEG than brightness.
Another thing your comparator must take into account is that edges usually lose accuracy on JPEG. So, your comparator should take into account that large pixel diferences should tolerate a larger diference in the comparison not only for the pixel being compared but also for the surrounding pixels.
Also bear in mind that if your comparator is visual then you can even align misaligned JPEG's. The key when using decompressed JPEG's for analysis or comparison is to always be tolerant to local diferences while paying more atention (and being more intolerant) to wide-scale diferences.
I hope this helps,
Rogério Rilhas
|
|
|
|
|
By the way: a JPEG can usually be decompressed to a raw bitmap format (a format where each pixel is represented by a 8-bit intensity red value, an 8-bit green value, and an 8-bit blue value). So, your decompressed image of say 200x300 pixels will, usually, result in a linear sequential flat array of 200x300x3 bytes.
To access the pixel at column 70 in line 20 you access the bytes (20*200+70)*3, (20*200+70)*3+1, and (20*200+70)*3+2. A luminance-only black and white decompression will usually result in a flat array of 200x300x1 (grayscale intensity value of 8 bits). There are variations when considering if line 70 is counted from the top or from the bottom. Also, the blue component may be the first of the 3 bytes and not the last. A good JPEG decompression will let you specify the resulting oientation and endian.
These can be considered raw formats, and comparisons can, thus, be made on a component-by-component basis.
Let me know if you need a way to decompress JPEG's to raw bitmap.
Rogério Rilhas
|
|
|
|
|
I've been reading a bit of this topic, and I think you are trying to do something with the wrong approach.
I think you need to render the image to a bitmap (CImage, ... ), and compare the resulting bitmaps or only sections of the images.
There are ton of image comparision algorithms on the web.
|
|
|
|
|
thank you that was simple and to the point appreciate it. will give it a shot.
|
|
|
|
|
Lowki wrote: thank you that was simple and to the point appreciate it. will give it a shot.
Once decoded, all images are stored (minus the header info) as a bitmap/pixmap in memory (don't read that as a Windows Bitmap, but rather what an actual bitmap is). Accessing the bytes as an array is easy and doesn't involve too much more than checking the byte alignment and/or BPP in the image.
|
|
|
|
|
Hi all,
Upon the start of my windows application I would like the splash screen window to move along the path of a cosine curve.
More precisely I would like it to work like this:
My splash window is positioned at the lower right corner of the screen. Now image a cosine graph under the interval of 0 <= degrees <= 180. I want the upper left corner of the splash screen to initially correspond to the coordinate of [180, cosine(180)]. Then, at some intervals I want the window to move to the "left" along the cosine curve all the way up to the top left corner of the screen, making a horizontally flipped S-shaped path (almost a flash-logo-like path).
Since screens vary in sizes I need to know how to transpose a cosine curve to "fit" all screens.
Any help would be greatly appreciated!!!!!
/Tommy
|
|
|
|
|
I don't know what language you're using, but I've always used ::GetSystemMetrics(SM_CXSCREEN) to get the screen width and similar calls to get other screen dimensions. For your problem, since cos(180)=-1 and cos(0)=1, you will want to find the center of the screen to pivot from, but to do this you will need to subtract off the height of the splash screen and any borders. The following worked in a dialog based app:
void CTestSplashDlg::SetPosition(double dDegrees)<br />
{<br />
const double pi = 3.1415926535;<br />
double dRadians = (2 * dDegrees * pi)/360;<br />
double dCos = cos(dRadians);<br />
<br />
CRect rect;<br />
GetClientRect(&rect);<br />
<br />
long nNewWidth = (long)(::GetSystemMetrics(SM_CXSCREEN) - rect.Width() - ::GetSystemMetrics(SM_CXDLGFRAME)) * (dDegrees/180);<br />
<br />
long nHeightCenter = (long)(::GetSystemMetrics(SM_CYSCREEN) - rect.Height() - ::GetSystemMetrics(SM_CYDLGFRAME) - ::GetSystemMetrics(SM_CYCAPTION))/2;<br />
long nNewHeight = (long)(nHeightCenter - (dCos * (nHeightCenter)));<br />
<br />
SetWindowPos(NULL, nNewWidth, nNewHeight, 0, 0, SWP_NOZORDER | SWP_NOSIZE);<br />
}
when called with:
for (double i = 180; i >= 0; i--)<br />
{<br />
SetPosition(i);<br />
Sleep(10);<br />
}
Note that you would probably call this from a timer instead of a for loop and the starting position does not take into account the taskbar that may be at the bottom of the screen.
|
|
|
|
|
hi this is my first post here
i want to change the frequency of part of a wave file
as you know we can change the Header of wave file and change the frequency of file totally and also it's possible by directsound palyback option
(buffer.setfrequency) but i want to do it dirctly in sample waves i mean i need some algorithm to change the frequency of given samples
any idea or algorithm?
(sorry for my bad english)
|
|
|
|
|
Hi,
You ask a very general question, so, to limit the possibilities, you must define more precisely your objective and any limitations:
1) Is your signal comfortably sampled, or is it on the limits? For example, a 44.1 KHz sampling rate has a signal limit of about 21 Khz or so, so these signals do not "fit inside" the sampling rate comfortably. If, on the other hand, you sampled a 10 KHz sound (voice) with a 44.1 KHz then it fits comfortably.
2) Is the new frequency always a multiple/submultiple of the original? Or is it arbitrarily diferent? If arbitrarily diferent then is it static or variable? For example, starting at 2:1 ratio and ending at 3:1 ratio?
3) Is the resulting quality very important? Or is it mathematical accuracy more important? Better accuracy implies better quality of course, but if you just want your resulting file to sound good then you may allow lower accuracy to simplify the algorithm.
4) Will you be able to use floating point? Or are you constrainded to using integers? Is performance important? If so, how many samples do you want to process per second? Or what is the real-time factor? If performance is very important then MMX/SSE may be necessary, that is why I ask.
5) Do you want to keep the same precision or can you use more precision in the result? For example, your source samples may be 16-bit and you may want the result in 32-bit floating point. If you want the sound to simply sound ok then I sugest you keep the original precision. If you want true mathematical accuracy then, in general, you should use higher precision than the original.
A lot more question could be asked before determining exactly what you want. Anyway, let me point out the most relevant aspects of the algorithm you need:
a) If the frequency is to be raised then the signal must be filtered to remove the frequencies that, after the frequency change, exceed half of the sampling rate. Variable filters (or parametric filters) may have a lowered performance and may be more complex to design.
b) After filtering the signal you generaly need to expand it into a new buffer (if the frequency is lowered), or, if the frequency is raised then you may do it in place. The most general form is to simply allocate a new buffer for both cases of lowering and raising the frequency.
c) Now that you have a destination buffer you must compute the new sample values. There are many ways to acomplish this, but maybe 2 can be considered interesting: linear interpolation and "real" interpolation. The first is simple but not very accurate, the second is complex but very accurate.
If you need more help on any of the questions (1->5) or steps (a->c) above then don't hesitate to ask. I kept the answer general while I don't know exactly what you want, but when you tell me what you want then I can give you a detailed algorithm.
I hope this helps,
Rilhas
|
|
|
|
|
Problem in question:
You may solve this problem with or without programming, but it has been optimised for solution with a programming method.
The Fibonacci sequence of numbers is defined as:
F[0]=0<br />
F[1]=1<br />
and for all x>1,<br />
F[x]=F[x-1]+F[x-2]
PLEASE do not post the answer.
What is the smallest value of x>0 such that F[x]=0 mod 2^32
PLEASE do not post the answer.
I never thought I'd revert to posting here to get help with this question from a Puzzel Challange Site[^]. The history behind it, I've been stuck on this for a year. Not a solid year but off and on. I've written a LongMath Class[^] to help me solve it but I still haven't found the the answer. I've read through the posts on the challange site and they're talk'n about, "If you understand the Fibonacci sequence you won't need a program to figure it out.
I'm looking for help in solving the problem on my own. The site is older and not alot of visitors to the forums. I've applied my LonMath Class to a sandbox app to help solve it but I'm not sure if I'm performing F[x]=0 mod 2^32 correctly. Fibonacci Pilot[^]
I'm listening but I only speak GEEK.
|
|
|
|
|
I'm intrigued, but I'm not about to log on to that site, is that the full text of the puzzle?
I ask because it seems to me that 0 mod 2^32 equals 0; so, as stated, the puzzle has no solution.
|
|
|
|